UINavigationBar背景设置什么的

2016-08-22  本文已影响263人  AlexDing

UINavigationBar 设置背景

//第一种情况
1)设置颜色
 [[UINavigationBar appearance] setBarTintColor:[UIColor greenColor]];
2)不调用下面方法设置图片
 - (void)setBackgroundImage:(nullable UIImage *)backgroundImage forBarMetrics:(UIBarMetrics)barMetrics
3)成功设置颜色
//第二种情况
1)设置颜色
 [[UINavigationBar appearance] setBarTintColor:[UIColor greenColor]];
2)调用下面方法设置图片
 - (void)setBackgroundImage:(nullable UIImage *)backgroundImage forBarMetrics:(UIBarMetrics)barMetrics
3)设置颜色看不到,仅能看到设置的背景图片
//第三种情况
1)设置颜色
 [[UINavigationBar appearance] setBarTintColor:[UIColor greenColor]];
2)调用下面方法设置空图片的UIImage
 [self setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
3)设置颜色看不到,仅能看到一个透明背景的UINavigationBar
上一篇 下一篇

猜你喜欢

热点阅读