self.navigationController.navigationBar.tintColor
方法二:
self.navigationController.navigationBar.layer.contents
= (id)[UIImage imageWithColor:youColor].CGImage;
方法三:
//使用分类方法
UINavigationBar 分类
#import <Foundation/Foundation.h>
@interface UINavigationBar (CustomImage)
- (void)drawRect:(CGRect)rect;
@end
#import "UINavigationBarCategory.h"
@implementation UINavigationBar (CustomImage)
- (void)drawRect:(CGRect)rect {
}
@end
另附:
//根据颜色返回图片
+(UIImage*) imageWithColor:(UIColor*)color
{
本文介绍了三种修改iOS应用中导航栏颜色的方法:一是通过设置navigationBar的tintcolor属性;二是利用UIImage填充navigationBar的layer.contents;三是创建UINavigationBar的分类,并重写drawRect方法来自定义导航栏的显示效果。
3万+

被折叠的 条评论
为什么被折叠?



