gpt4 book ai didi

ios - 标签栏图标显示不正确

转载 作者:行者123 更新时间:2023-11-29 02:03:18 25 4
gpt4 key购买 nike

在我的应用程序中有一个带有四个选项卡的标签栏。我将标签栏图标资源 (50x50) 添加到 Images.xcassets 中。但是我发现其中一个icosn显示不正确,如下图:

tab bar image

- (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

当我把第一个图标换成另一个时,好像没问题,但我想用这个:

tab image

最佳答案

问题似乎出在色调上。 Tint color 改变图像可见像素的颜色,所以它通常用于改变具有透明度的图像的颜色。好像你的图像没有透明背景,所以色调颜色使它全蓝。请检查您的图像来源。如果您的图像很好,另一种可能的解决方案 - 在设置图像之前使用图像渲染模式:

UIImage *toSet = [yourImage  imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];

关于ios - 标签栏图标显示不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30096975/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com