方法一
@implementation UINavigationBar (UINavigationBarCategory)
- (void)drawRect:(CGRect)rect {
//加入旋转坐标系代码
// Drawing code
UIImage *navBarImage = [UIImage imageNamed:@"navibar.png"];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(context, 0.0, self.frame.size.height);
CGContextScaleCTM(context, 1.0, -1.0);
CGPoint center=self.center;
CGImageRef cgImage= CGImageCreateWithImageInRect(navBarImage.CGImage, CGRectMake(0, 0, 1, 44));
CGContextDrawImage(context, CGRectMake(center.x-160-80, 0, 80, self.frame.size.height), cgImage);
CGContextDrawImage(context, CGRectMake(center.x-160, 0, 320, self.frame.size.height), navBarImage.CGImage);
CGContextDrawImage(context, CGRectMake(center.x+160, 0, 80, self.frame.size.height), cgImage);CGImageRelease(cgImage);
}
@end
方法二
UINavigationController *navi =。。。。
UIImage *image = [UIImage imageNamed:@"navibar.jpg"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
[navi.navigationBar addSubview:imageView];
[navi.navigationBar sendSubviewToBack:imageView];
[imageView release];
ios 5
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 50000
if ([self.navigationController.navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)]){
CLog(@"111");
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navi.png"] forBarMetrics:UIBarMetricsDefault];
}
#endif
方法三,没成功
+ (UIColor *)colorWithPatternImage:(UIImage *)image; //也就是说其实UIColor可以表示的不仅仅是纯色,也可以是一张图片
UIImage *navBarImage = [UIImage imageNamed:@"LOGO_320×44.png"];
UIColor *backgroundColor = [UIColor colorWithPatternImage: navBarImage];//因为是pattern的缘故,所以最好提供和bar一样大小的图片。
UINavigationBar.backgroundColor = backgroundColor;
分享到:
相关推荐
微信小程序 自定义tabbar (源码)微信小程序 自定义tabbar (源码)微信小程序 自定义tabbar (源码)微信小程序 自定义tabbar (源码)微信小程序 自定义tabbar (源码)微信小程序 自定义tabbar (源码)微信小程序 自定义...
小程序自定义tabbar,覆盖默认tabbar,实现中间凸起功能和样式,包括html和js
React Native的自定义图标支持NavBar/TabBar/ToolbarAndroid,图像源和完整的样式
uniapp自定义tabbar图标样式uniapp自定义tabbar图标样式
Flutter自定义TabBar的Indicator 实现秒杀Tab效果
⊙ 支持自定义tabBar动画 ⊙ 支持自定义tabBar样式 ⊙ 支持自定义badgeValue动画 ⊙ 支持自定义badgeValue样式 ⊙ 完美支持横竖屏 ⊙ 支持CocoaPods 更多说明请移步github github地址: ...
uniapp小程序自定义动态tabbar
"selectedIconPath": "images/tabBar/home_1.png" }, { "text": "搜索", "pagePath": "pages/search/search", "iconPath": "images/tabBar/search.png", "selectedIconPath": "images/tabBar/search1.png" }...
微信小程序源码(含截图)自定义tabbar微信小程序源码(含截图)自定义tabbar微信小程序源码(含截图)自定义tabbar微信小程序源码(含截图)自定义tabbar微信小程序源码(含截图)自定义tabbar微信小程序源码(含...
由于项目中经常需要用到自定义的Tabbar,原生的Tabbar可自定义性有局限性,将在之前编写的组件集成整理,弄出一个通用的组件。 Github:插件市场:H5演示:如果问题最好去github反馈...tabbar/lb-tabbar-item.vue " }}
mpvue 自定义小程序tabBar
ios开发,swift语言,自定义的tabbar按钮,中间突出。
iOS自定义tabBar(包含OC和Swift版) 特点 1.方便自定义TabBar每个TabBarItem选中文本和未选中文本样式以及图片 2.通过Block控制TabBarItem能不能选中(可用于如登录控制等) 3.切换TabBarItem更简单 OC版仓库...
自定义弧形tabBar,tabbar点击水波纹动画,及其UIwebView中oc和js相互调用示例
学习Flex.flex源程序,很好的啊。
自定义tabbar的功能 实现页面切换 按钮自定义回调 可真机或模拟器运行
小程序源码 自定义tabbar (代码+截图)小程序源码 自定义tabbar (代码+截图)小程序源码 自定义tabbar (代码+截图)小程序源码 自定义tabbar (代码+截图)小程序源码 自定义tabbar (代码+截图)小程序源码 自定义tabbar ...
自定义Tabbar
自定义UITabbar ,自定义tabbar的button
iphone开发技巧UI篇之自定义TabBar iphone开发技巧UI篇之自定义TabBar iphone开发技巧UI篇之自定义TabBar