iOS7 - Change UINavigationBar border color

后端 未结 15 2069
时光取名叫无心
时光取名叫无心 2020-12-07 14:44

Is it possible to change the grey border-bottom color of the UINavigationBar in iOS7?

I already tried to remove to border, but this is not working:

[         


        
15条回答
  •  情书的邮戳
    2020-12-07 15:31

    Here's the method for creating image with clear color:

    + (UIImage*)imageFromColor:(UIColor *)color withSize:(CGSize)sizeImage
    {
        UIImage *resultImage = nil;
    
        UIGraphicsBeginImageContext(sizeImage);
    
        CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(), color.CGColor);
        CGContextFillRect(UIGraphicsGetCurrentContext(), CGRectMake(0.0f, 0.0f, sizeImage.width, sizeImage.height));
        resultImage = UIGraphicsGetImageFromCurrentImageContext();
    
        UIGraphicsEndImageContext();
    
        return resultImage;
    }
    

    Here's it's usage for removing annoying bottom line:

    navigationBar.shadowImage = [UIImage imageFromColor:[UIColor clearColor] withSize:CGSizeMake(1.0f, 1.0f)];
    

提交回复
热议问题