[ios]UITabBarItem 更改图像的高度和宽度
来源:互联网 发布:电脑屏幕视频录制软件 编辑:程序博客网 时间:2024/06/10 02:48
我有没有标题和图像只有 UITabBarItem。我想知道我如何能改变图像大小所以它可以占用整个 UITabBarItem。
我找遍整个互联网,但什么也没找到。
我试过:
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);
但什么都没有改变。
从苹果文档的最大大小的一张图片在 TabBar 是 30 x 30 (60 x 60 的视网膜显示器)。
我不认为它是可能采取整个 TabBar 不拉伸图像的高度。我认为最好的解决办法是中心中使用 imageInset TabBar 的图像
tabBarItem1.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
否则你可以玩这 imageInset 和拉伸图像像在截图中
tabBarItem1.imageInsets = UIEdgeInsetsMake(0, -10, -6, -10);
- (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);
}
0 0
- [ios]UITabBarItem 更改图像的高度和宽度
- UITabBarItem 更改图像的高度和宽度
- UITabBarItem 更改图像的高度和宽度/UINavigationBar 更改样式
- h264图像宽度和高度
- IOS 获取文本的高度和宽度
- iOS Label的宽度和高度自适应
- iOS 计算label的宽度和高度
- 如何改变Image对象中图像的宽度和高度
- IOS更改UITabBarItem的图片及字体颜色
- iOS 获取label的text的宽度和高度
- ios动态获取UILabel的高度和宽度
- IOS中如何获取string的宽度和高度
- IOS修改图片的像素(高度和宽度)
- ios动态获取UILabel的高度和宽度
- ios动态获取UILabel的高度和宽度
- iOS中如何动态获取label的宽度和高度
- [IOS 开发] NSString-计算文本的宽度和高度
- iOS 动态设置UILabel的frame(宽度和高度)
- Android搭建项目框架
- Runtime实战之定制TabBarItem大小(京东tabar实现机制)
- python连接两个字符串的另外两种高效率的方法
- Unity文件目录的读写
- 使用html和css制作水平导航栏nav
- [ios]UITabBarItem 更改图像的高度和宽度
- C预处理指令
- C++的const操作符
- Linux常用命令笔记
- iOS后台模式以及后台持续运行
- UploadiFive基本用法和配置
- 细说linux系统调用--使用c和汇编进行系统调用
- IOS app上交提交包时出现ERROR ITMS-90535 ITMS-90542 ITMS-90207
- hdu 4997 状压dp