我正在开发objective-C。我想改变标签栏背景,如下图:
代码如下:
UIImage *tabBarBackground = [UIImage imageNamed:@"tabbaritem_background.png"];
[[UITabBar appearance] setBackgroundImage:tabBarBackground];
但是设置背景图片后,背景不在正确的位置,如下所示:背景图像应该像上图的背景一样放在底部。
我错过了什么吗?有人能帮我吗 ?
提前致谢。
最佳答案
我认为是您出错的地方,请检查是否是以下步骤:
ViewController.m
您可以设置标签栏免费颜色:- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[[UITabBar appearance] setBackgroundColor:[UIColor grayColor]]; // Here you can set the converted color form image, make sure the imageSize fit.
}
关于ios - 如何在 Objective-C 中更改标签栏的背景图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42287662/