In my delegate doing the didFinishLaunchingWithOptions function, I am trying to customize the look of my navigation bar.
[UINavigationBar appearance].translucent = NO; [[UINavigationBar appearance] setBackgroundImage:[UIImage imageWithColor:[UIColor whiteColor] size:CGSizeMake(1.0f, 1.0f) ] forBarMetrics:UIBarMetricsDefault ]; [UINavigationBar appearance].shadowImage = [UIImage imageWithColor:[UIColor redColor] size:CGSizeMake(0.5f, 0.5f) ];
I expect a red shadow 1px thick is high. Instead, they give me a 2px high translucent red shadow. How can it look the way I want? I made similar appearance settings for UITabBar. This, on the other hand, behaves well.

The category function that creates dynamic images is defined as follows:
+ (UIImage*)imageWithColor:(UIColor *)color size:(CGSize)size { CGRect rect = CGRectMake(0.0f, 0.0f, size.width, size.height); UIGraphicsBeginImageContext(rect.size); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(context, [color CGColor]); CGContextFillRect(context, rect); UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return image; }
ios cocoa-touch uinavigationbar uiappearance
Pwner
source share