gpt4 book ai didi

ios - 如何使标签栏图标图像变小?

转载 作者:行者123 更新时间:2023-11-28 21:38:31 24 4
gpt4 key购买 nike

我想让标签栏图标图片看起来有点小。我使用了 30*30 大小的图片和 60*60 的图片。但它仍然对我不起作用。请指导我如何获得正确的图片解决方案。

以下是我的代码

//set the custom images for selected & unselected image for tab bar
UITabBarItem *homeTab = [self.exposeTabBar.items objectAtIndex:0];
UIImage *home_unselectedImage = [UIImage imageNamed:@"home.png"];
UIImage *home_selectedImage = [UIImage imageNamed:@"home.png"];
[homeTab setImage: [home_unselectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[homeTab setSelectedImage: home_selectedImage];

UITabBarItem *bookmarkTab = [self.exposeTabBar.items objectAtIndex:1];
UIImage *bookmark_unselectedImage_ = [UIImage imageNamed:@"bookmark.png"];
UIImage *bookmark_selectedImage = [UIImage imageNamed:@"bookmark.png"];
[bookmarkTab setImage: [bookmark_unselectedImage_ imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[bookmarkTab setSelectedImage: bookmark_selectedImage];

UITabBarItem *postTab = [self.exposeTabBar.items objectAtIndex:2];
UIImage *post_unselectedImage_ = [UIImage imageNamed:@"create-post.png"];
UIImage *post_selectedImage = [UIImage imageNamed:@"create-post_white.png"];
[postTab setImage: [post_unselectedImage_ imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[postTab setSelectedImage: post_selectedImage];

UITabBarItem *notificationTab = [self.exposeTabBar.items objectAtIndex:3];
UIImage *notification_unselectedImage_ = [UIImage imageNamed:@"notifications.png"];
UIImage *notification_selectedImage = [UIImage imageNamed:@"notifications_white.png"];
[notificationTab setImage: [notification_unselectedImage_ imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[notificationTab setSelectedImage: notification_selectedImage];

UITabBarItem *profileTab = [self.exposeTabBar.items objectAtIndex:4];
UIImage *profile_unselectedImage_ = [UIImage imageNamed:@"more.png"];
UIImage *profile_selectedImage = [UIImage imageNamed:@"more_white.png"];
[profileTab setImage: [profile_unselectedImage_ imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[profileTab setSelectedImage: profile_selectedImage];

self.exposeTabBar.tintColor = [UIColor whiteColor];
self.exposeTabBar.selectedImageTintColor=[UIColor whiteColor];


[[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName : [UIColor blackColor] }
forState:UIControlStateNormal];
[[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName : [UIColor whiteColor] }
forState:UIControlStateSelected];

最佳答案

使用以下类似的代码来设置 UITabBar 的图像。

UITabBarItem *i0 = [self.tabBar.tabBar.items objectAtIndex:0];
[i0 setImage:[UIImage imageNamed:@"home"]];

它正在处理我的情况。

关于ios - 如何使标签栏图标图像变小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33011817/

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