本文介绍了如何删除UITabBarItem selectionImage填充?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我通过UITabBar外观将SelectionIndicatorImage设置为可伸缩图像(以适应各种设备宽度):
I am setting the SelectionIndicatorImage as a stretchable image (to accommodate for various device widths) via UITabBar appearance:
UIImage *selectedImage = [[UIImage imageNamed:@"SelectedTab"] stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[[UITabBar appearance] setSelectionIndicatorImage:selectedImage];
结果我在屏幕边缘获得了2pt填充。我基本上试图使用选择指标作为当前所选UITabBarItem的背景。
As a result I get a 2pt padding on the screen edges. I am basically trying to use selection indicator as a background for currently selected UITabBarItem.
什么是简单的解决方法这个?
What would be an easy way to solve this?
推荐答案
如果你想在你的应用程序中使用带有选择和取消选择功能的UITabBarController那么你应该这个代码
If you want to use UITabBarController in your app with selection and unselection feature then you should this code
[[self.tabBarController tabBar] setBackgroundImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"bg_tabBar" ofType:@"png"]]];
[[self.tabBarController tabBar] setSelectionIndicatorImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"bg_tabItem_selected" ofType:@"png"]]];
NSArray *arrTabItems = [[self.tabBarController tabBar] items];
UITabBarItem *tabBarItem = [arrTabItems objectAtIndex:0];
[tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"img_selected.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"img_unselected.png"]];
[tabBarItem setImageInsets:UIEdgeInsetsMake(5, 5, 0, 5)];
这篇关于如何删除UITabBarItem selectionImage填充?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!