试试这个:[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
解决方案 »
- iOS开发未来趋势是怎样,请各位大虾指点下!!!
- xcode4.2 storyboard点击editor 视图编辑界面出不来了
- ★★★★iPhone怎么实现自动调整页面大小的?
- 请问做IOS开发的都是在黑苹果上做的吗
- 开发者选项有什么用?
- ios 表格 实现自定义下拉刷新
- 请高手指点迷津
- 彧 这个字 牛逼的你能使用NSJSONSerializtion 通过网络请求获取到这个字吗?,下面给出接口
- UIwebview html中的图片异步加载怎么实现 ?
- 求助困扰好几天了55555
- 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