试试这个:[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
解决方案 »
- AudioServicesCreateSystemSoundID在系统静音时都能听得到?
- 为什么报错呀
- 菜鸟在学ios开发,想往UI设计方面发展,求大神指点迷津
- IOS中用ASIFormDataRequest POST出錯
- 用TabBar的item按钮图片分辨率应该是做成多大的啊?
- 请问这里加的一个按钮怎么显示不出来
- uiwebview加载图片的问题
- 请问 id <EveryFrameDelegate> 这是什么语法?为什么这里要加尖括号?
- storyboard下view视图的label、button不能按住control拖进头文件
- iOS录制视频并压缩上传
- 100分 悬赏 IOS HTML encode 问题
- 求分享一个iphone上能实现电影院影厅展示,选座,缩放并带有坐标的页面代码
求解……
你只能把它设置为你想要的颜色(或图片)
似乎背景图达不到你要的效果了,因为背景图是draw在NavigationBar上的,而你要的效果是有一部分超出NavigationBar,可以尝试在NavigationBar上插入一个ImageView,sendToBack,ImageView如果被NavigationBar截断了,没有显示出那个锯齿,就设置下NavigationBar的clipToBounds
似乎背景图达不到你要的效果了,因为背景图是draw在NavigationBar上的,而你要的效果是有一部分超出NavigationBar,可以尝试在NavigationBar上插入一个ImageView,sendToBack,ImageView如果被NavigationBar截断了,没有显示出那个锯齿,就设置下NavigationBar的clipToBounds 恩 哥们 这种方法虽然可以 但是顶部会覆盖掉返回按钮和titile
似乎背景图达不到你要的效果了,因为背景图是draw在NavigationBar上的,而你要的效果是有一部分超出NavigationBar,可以尝试在NavigationBar上插入一个ImageView,sendToBack,ImageView如果被NavigationBar截断了,没有显示出那个锯齿,就设置下NavigationBar的clipToBounds 恩 哥们 这种方法虽然可以 但是顶部会覆盖掉返回按钮和titile
我试了下,可以的,你应该没有使用sendToBack:@interface CustomNavigationBar : UINavigationBar@end@implementation CustomNavigationBar- (void)drawRect:(CGRect)rect {
self.clipsToBounds = NO;
UIImage *image = [CustomNavigationBar imageFromColor:[UIColor colorWithRed:0.3 green:0.4 blue:0.8 alpha:1]];
UIImageView *backgroundImageView = [[UIImageView alloc] initWithImage:image];
backgroundImageView.frame = CGRectMake(0, 0, CGRectGetWidth(rect), CGRectGetHeight(rect) + 20);
[self addSubview:backgroundImageView];
[self sendSubviewToBack:backgroundImageView];
}+ (UIImage *)imageFromColor:(UIColor *)color {
CGRect rect = CGRectMake(0, 0, 1, 1);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, color.CGColor);
CGContextFillRect(context, rect);
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}@end@implementation UINavigationBar (GlobalBackgroundImage)+ (Class)class {
return NSClassFromString(@"CustomNavigationBar");
}- (void)drawRect:(CGRect)rect {
self.clipsToBounds = NO;
}@end如果NavigationBar是在SB里建立的,要改下Class