美文网首页
UINavigationBar背景设置什么的

UINavigationBar背景设置什么的

作者: AlexDing | 来源:发表于2016-08-22 14:57 被阅读263次

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

相关文章

网友评论

      本文标题:UINavigationBar背景设置什么的

      本文链接:https://www.haomeiwen.com/subject/fkqgsttx.html