如何在 UITabBarController 中设置 TabBar Image

How to set TabBar Image in UITabBarController

我在申请中使用了UITabBarController

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

有时它会在选项卡之间创建 space。如果我更改 image size,那么有时它看起来会很模糊。

我放了普通图,@2x还有@3x

@3x - 312*180

@2x - 160*120

normal - 80*56

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

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

这是我的代码,

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

按照 Apple 提供的 IconMatrix Guide 进行操作。你会得到一切..

您应该始终将 HIGH 设计为:https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/IconMatrix.html#//apple_ref/doc/uid/TP40006556-CH27-SW1