[英]How to set Image in Tabbar not Tint color in ios?
我有一个带有UITabbar
的应用程序,我想在Tabbar中设置图像,但无法在Tabbar中设置图像。 我可以将图像设置为Tabbar中的样子,而不是像图像那样获得色调的图像形状吗? 。
我尝试过此代码,但无法设置图像。
UITabBar *tabBar = self.tabBar;
UITabBarItem *targetTabBarItem = [[tabbar items] objectAtIndex:0]; // whichever tab-item
UIImage *selectedIcon = [UIImage imageNamed:@"name-of-selected-image.png"];
[targetTabBarItem setSelectedImage:selectedIcon];
选择您的TabBar项,然后像这样设置图像
要么
设置所选的色彩尝试
[[UITabBar appearance] setTintColor:[UIColor whiteColor]];
[UITabBarItem.appearance setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]} forState:UIControlStateNormal];
[[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"name-of-selected-image.png"]];
[[UITabBar appearance]setSelectedItem:[[UITabBar appearance].items objectAtIndex:2]];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.