gpt4 book ai didi

ios - 如何在 UITabBarController 中设置 TabBar Image

转载 作者:行者123 更新时间:2023-11-28 19:49:43 26 4
gpt4 key购买 nike

我在我的应用程序中使用了 UITabBarController

我真的很困惑 UITabBar 应该有什么 image size。它必须支持所有设备。 iPhone 4s,5,5s,5c,6,6 plus

有时它会在选项卡之间创建空间。如果我更改图像大小,有时它看起来会很模糊。

我放了普通图片,@2x@3x

@3x - 312*180

@2x - 160*120

normal - 80*56

所以根据我的理解,iPhone 6 应该拍摄 @2x 图像,但它没有拍摄。 iPhone 6 中的选项卡之间有空格。所以我以编程方式为 iPhone 6 设置图像并将其大小设置为 93*56。然后选项卡之间的空格已被删除并正确设置。但是现在我面临什么问题。图像在 iPhone 6 中看起来很模糊。现在不知道该怎么办。

有人可以帮我解决这个问题吗?如何管理支持所有设备的选项卡图像。提前致谢!

enter image description here这是我的代码,

- (BOOL)application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions {
// Override point for customization after application launch.

UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

UITabBarController *tabController = [[UITabBarController alloc]init];

UINavigationController *navController1 = [[UINavigationController alloc]initWithRootViewController:[storyBoard instantiateViewControllerWithIdentifier:@"ViewController1"]];

UINavigationController *navController2 = [[UINavigationController alloc]initWithRootViewController:[storyBoard instantiateViewControllerWithIdentifier:@"ViewController2"]];

UINavigationController *navController3 = [[UINavigationController alloc]initWithRootViewController:[storyBoard instantiateViewControllerWithIdentifier:@"ViewController3"]];

UINavigationController *navController4 = [[UINavigationController alloc]initWithRootViewController:[storyBoard instantiateViewControllerWithIdentifier:@"ViewController4"]];

tabController.viewControllers = [NSArray arrayWithObjects:navController1, navController2, navController3, navController4, nil];


[[[tabController.viewControllers objectAtIndex:0] tabBarItem]setFinishedSelectedImage:[UIImage imageNamed:@"chords-active1.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"chords1.png"]];

[[[tabController.viewControllers objectAtIndex:2] tabBarItem]setFinishedSelectedImage:[UIImage imageNamed:@"progression-active1.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"progression1.png"]];

[[[tabController.viewControllers objectAtIndex:1] tabBarItem]setFinishedSelectedImage:[UIImage imageNamed:@"practice-selected.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"practice.png"]];

[[[tabController.viewControllers objectAtIndex:3] tabBarItem]setFinishedSelectedImage:[UIImage imageNamed:@"settings-active1.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"settings1.png"]];

self.window.rootViewController = tabController;

return YES;
}

最佳答案

关注这个IconMatrix Guide由苹果公司提供。你会得到一切..

关于ios - 如何在 UITabBarController 中设置 TabBar Image,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29935798/

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