更改导航栏背景色以及半透明效果

2016-04-28  本文已影响202人  JackMayx

直接在

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {}

这个方法里面加上就可以了

///修改导航栏背景颜色和标题文字颜色

///导航栏背景色

let color = UIColor .whiteColor()

let bar = UINavigationBar.appearance();

bar.shadowImage = UIImage();

bar.barStyle = .Default;

bar.titleTextAttributes = [NSForegroundColorAttributeName:UIColor .blackColor()];

bar.setBackgroundImage(UIImage(color: color), forBarMetrics: UIBarMetrics.Default);

bar.translucent = true;

///封装方法

+ (UIColor *)colorWithImage:(NSString *)imageNamed{

return [UIColor colorWithPatternImage:[UIImage imageWithName:imageNamed]];

}

+ (UIImage *)imageWithName:(NSString *)name{

NSString *bundlePath = [[NSBundle mainBundle] bundlePath];

NSString *filePath = [bundlePath stringByAppendingPathComponent:name];

UIImage *img = [UIImage imageWithContentsOfFile:filePath];

return img;

}

上一篇下一篇

猜你喜欢

热点阅读