移除navbar下横线 和 tabbar上横线 颜色转图片
2016-04-27 11:05
459 查看
//颜色转图片
+ (UIImage *)imageWithColor:(UIColor *)color {
CGRect rect = CGRectMake(0.0f,0.0f,
1.0f,1.0f);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
//移除tabbar上面的线 image为透明图
UIImage* tabBarBackground = image;
[[UITabBar appearance] setShadowImage:tabBarBackground];
[[UITabBar appearance] setBackgroundImage:tabBarBackground];
//移除navbar下面的线
if ([self.navigationController.navigationBarrespondsToSelector:@selector( setBackgroundImage:forBarMetrics:)]){
NSArray *list=self.navigationController.navigationBar.subviews;
for (id objin list) {
if ([obj isKindOfClass:[UIImageViewclass]]) {
UIImageView *imageView=(UIImageView *)obj;
NSArray *list2=imageView.subviews;
for (id obj2in list2) {
if ([obj2isKindOfClass:[UIImageViewclass]]) {
UIImageView *imageView2=(UIImageView *)obj2;
imageView2.hidden=YES;
}
}
}
}
}
+ (UIImage *)imageWithColor:(UIColor *)color {
CGRect rect = CGRectMake(0.0f,0.0f,
1.0f,1.0f);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
//移除tabbar上面的线 image为透明图
UIImage* tabBarBackground = image;
[[UITabBar appearance] setShadowImage:tabBarBackground];
[[UITabBar appearance] setBackgroundImage:tabBarBackground];
//移除navbar下面的线
if ([self.navigationController.navigationBarrespondsToSelector:@selector( setBackgroundImage:forBarMetrics:)]){
NSArray *list=self.navigationController.navigationBar.subviews;
for (id objin list) {
if ([obj isKindOfClass:[UIImageViewclass]]) {
UIImageView *imageView=(UIImageView *)obj;
NSArray *list2=imageView.subviews;
for (id obj2in list2) {
if ([obj2isKindOfClass:[UIImageViewclass]]) {
UIImageView *imageView2=(UIImageView *)obj2;
imageView2.hidden=YES;
}
}
}
}
}
相关文章推荐
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 不可修补的 iOS 漏洞可能导致 iPhone 4s 到 iPhone X 永久越狱
- iOS 12.4 系统遭黑客破解,漏洞危及数百万用户
- 如何成为一名专家级的开发人员
- 每日安全资讯:NSO,一家专业入侵 iPhone 的神秘公司
- [转][源代码]Comex公布JailbreakMe 3.0源代码
- gitinspector+jenkins 开发代码统计CI
- .NET微信公众号开发之公众号消息处理
- Node.js开发者必须了解的4个JS要点
- 使用nodejs开发cli项目实例
- 谷歌Chrome浏览器扩展程序开发小记
- nodejs开发微博实例
- Egret引擎开发指南之创建项目
- Android开发自学笔记(二):工程文件剖析
- Java开发人员需知的十大戒律
- Web 开发常用工具 大家自己查找下载
- 三种Web开发主流技术的性价评价
- 在B/S开发中经常用到的JavaScript技术第1/3页