UINavigationBar背景设置什么的

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背景设置什么的)