0
在我的應用程序中有一個帶有四個選項卡的Tabbar。我將標籤欄圖標資源(50x50)添加到Images.xcassets
中。但我發現,icosn的一個顯示不正確,如下圖:Tabbar圖標顯示不正確
- (void)customTabBarItems{
self.tabBar.superview.backgroundColor = [UIColor whiteColor];
NSArray *items = self.tabBar.items;
NSArray *normalImgs = @[@"tab_home_normal",@"tab_message_normal",@"tab_order_normal",@"tab_userCenter_normal"];
NSArray *selectedImgs = @[@"tab_home_selected",@"tab_message_selected",@"tab_order_selected",@"tab_userCenter_selected"];
for (NSInteger i = 0; i < items.count; i++) {
UITabBarItem *item = [items objectAtIndex:i];
NSString *title = titleArr[i];
UIImage *normalImg = [UIImage imageNamed:normalImgs[i]];
UIImage *selectImg = [UIImage imageNamed:selectedImgs[i]];
item.title = title;
if (isIOS7Later) {
item.image = normalImg;
item.selectedImage = selectImg;
}
else{
[item setFinishedSelectedImage:selectImg withFinishedUnselectedImage:normalImg];
}
}
}
//set tint color
- (void)_customAppearance
{
if (isIOS7Later)
{
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:NO];
}
UIColor * color = [UIColor whiteColor];
NSDictionary * dict = [NSDictionary dictionaryWithObject:color forKey:UITextAttributeTextColor];
[[UINavigationBar appearance] setTitleTextAttributes:dict];
if (isIOS7Later)
{
[[UITabBar appearance] setTintColor:BGCOLOR(21.0, 170.0, 255.0, 1.0)];
}
else
{
NSDictionary *textAttributesNormal = @{UITextAttributeTextColor: BGCOLOR(179, 179, 179, 1)};
NSDictionary *textAttributesSelected = @{UITextAttributeTextColor:BGCOLOR(0, 154, 255, 1)};
[[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:@"tab_select_image"]];
[[UITabBarItem appearance] setTitleTextAttributes:textAttributesNormal forState:UIControlStateNormal];
[[UITabBarItem appearance] setTitleTextAttributes:textAttributesSelected forState:UIControlStateSelected];
[[UITabBar appearance] setSelectedImageTintColor:[UIColor whiteColor]];
[[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"tab_select_image"]];
}
[SVProgressHUD setForegroundColor:BGCOLOR(0, 135.0, 231, 1)];
[SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeBlack];
}
//Images.xcassets
當我改變了第一個圖標到另一個,它似乎確定,但我想用這一個:
作爲未來職位的備註:正確設置代碼格式。如果你這樣做,人們會做出更好的反應。 – Peanut
@steven嘗試正確發佈問題... –
「HUI」白色部分是透明的還是實際上是白色的? –