您的位置:首页 > 编程语言 > VB

移除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;

                }

            }

        }

    }

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息