我想让标签标签栏图标图像看起来有点小。我使用了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];
答案 0 :(得分:1)
使用以下同样明智的代码来设置UITabBar的图像。
UITabBarItem *i0 = [self.tabBar.tabBar.items objectAtIndex:0];
[i0 setImage:[UIImage imageNamed:@"home"]];
它处理我的案子。
答案 1 :(得分:1)
尝试设置123456789
并使用值,直到它符合您的需要。
imageInsets