Ios UItabaritem更改图像高度和宽度

Ios UItabaritem更改图像高度和宽度,ios,uitabbar,uitabbaritem,Ios,Uitabbar,Uitabbaritem,我有一个没有标题只有图像的Uitabritem。我想知道如何更改图像大小,使其能够占据整个图像 我在网上到处搜索,但什么也没找到 我试过: UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main_Storyboard" bundle:nil]; UITabBarController *tabBarController = [storyBoard instantiateViewControllerWithIdentifi

我有一个没有标题只有图像的Uitabritem。我想知道如何更改图像大小,使其能够占据整个图像

我在网上到处搜索,但什么也没找到

我试过:

UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main_Storyboard" bundle:nil];
UITabBarController *tabBarController = [storyBoard instantiateViewControllerWithIdentifier:@"tab"];
UITabBar *tabBar = tabBarController.tabBar;
UITabBarItem *tabBarItem1 = [tabBar.items objectAtIndex:0];
UITabBarItem *tabBarItem2 = [tabBar.items objectAtIndex:1];
UITabBarItem *tabBarItem3 = [tabBar.items objectAtIndex:2];

tabBarItem1.imageInsets = UIEdgeInsetsMake(0, -10, -6, -10);
但一切都没有改变


谢谢大家!

根据苹果的文档,标签栏上图片的最大尺寸为30x30(视网膜显示器为60x60)

我不认为在不拉伸图像的情况下,可以获取标签栏的整个高度。我认为最好的解决方案是使用imageInset将图像居中放置在选项卡栏中

tabBarItem1.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);

否则,您可以使用此图像插入并像屏幕截图中那样拉伸图像

tabBarItem1.imageInsets = UIEdgeInsetsMake(0, -10, -6, -10);


检查我的编辑answer@llario仍然没有让我看到你的修改code@llario刚刚编辑question@llario它很管用,谢谢!非常感谢您的回答。现在我的应用程序看起来非常漂亮:)@Android_kalai很高兴能帮上忙;-)嘿,点击两次图片。它的规模:SDid你找到一个解决方案时,图像缩放点击两次?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions  {


 UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;

 UITabBar *tabBar = tabBarController.tabBar;
 UITabBarItem *tabBarItem1 = [tabBar.items objectAtIndex:0];
 UITabBarItem *tabBarItem2 = [tabBar.items objectAtIndex:1];
 UITabBarItem *tabBarItem3 = [tabBar.items objectAtIndex:2];

 //add image to tabbarItems

 tabBarItem1.imageInsets = UIEdgeInsetsMake(0, -10, -6, -10);
}