嗨,我是新手到iOS。标签栏选择指标不工作
我已经通过Storyboard实现了tabBarController以及4个tabBar项目。现在,我需要自定义我的标签栏,如下图所示。我为标签栏设置了背景。
+ (UIImage *)imageFromColor:(UIColor *)color {
CGRect rect = CGRectMake(0, 0, 1, 1);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[UITabBar appearance] setTintColor:[UIColor whiteColor]];
[[UITabBar appearance] setBackgroundImage:[AppDelegate imageFromColor:[UIColor blackColor]]];
return YES;
}
设置标签栏的背景没有任何问题。
当我尝试设置所选标签栏项目的颜色时,它不起作用。我不知道为什么?
[[UITabBar appearance]setSelectionIndicatorImage:[AppDelegate imageFromColor:[UIColor orangeColor]]];
我需要定制我这样的标签栏:
我该怎么办呢?
我已经在AppDelegate.m本身添加它 – remyr3my
连这个只设置背景 – remyr3my