iOS 使用系统的UITabBarController 修改展示的图片大小
1. 设置TabBarItem图片的大小
1 - (void)configurationAppTabBarAndNavigationBar
{
// 选中的item普通状态图片的大小
UIImage *normalImage = self.navigationController.tabBarController.tabBar.selectedItem.image;
UIImage *tabNormalImage = [ToolObject createNewImageWithColor:normalImage multiple:1.1];
tabNormalImage = [tabNormalImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
[self.navigationController.tabBarController.tabBar.selectedItem setImage:tabNormalImage];
// 选中的item选中撞他图片的大小
UIImage *selectImage = self.navigationController.tabBarController.tabBar.selectedItem.selectedImage;
UIImage *tabSelectImage = [self createNewImageWithColor:selectImage multiple:1.1];
tabSelectImage = [tabSelectImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];12 // 设置点击图片放大缩小的动画
[self.navigationController.tabBarController.tabBar.selectedItem setSelectedImage:tabSelectImage];
self.navigationController.tabBarController.tabBar.tintColor = [UIColor colorWithRed:0.11f green:0.61f blue:0.97f alpha:1.00f];
self.navigationController.tabBarController.tabBar.barTintColor = [UIColor colorWithRed:0.85f green:0.85f blue:0.85f alpha:1.00f];
}
2.图片放大或压缩处理 ,图片放大倍数 0 ~ 2 之间 ,0~1 缩小图片,1~2 放大图片
1 /**
* 根据image 返回放大或缩小之后的图片
*
* @param image 原始图片
* @param multiple 放大倍数 0 ~ 2 之间
*
* @return 新的image
*/
+ (UIImage *) createNewImageWithColor:(UIImage *)image multiple:(CGFloat)multiple
{
CGFloat newMultiple = multiple;
) {
newMultiple = ;
}
&& fabs(multiple) < ) || (fabs(multiple)> && fabs(multiple)<))
{
newMultiple = multiple;
}
else
{
newMultiple = ;
}
CGFloat w = image.size.width*newMultiple;
CGFloat h = image.size.height*newMultiple;
CGFloat scale = [UIScreen mainScreen].scale;
UIImage *tempImage = nil;
CGRect imageFrame = CGRectMake(, , w, h);
UIGraphicsBeginImageContextWithOptions(image.size, NO, scale);
[[UIBezierPath bezierPathWithRoundedRect:imageFrame cornerRadius:] addClip];
[image drawInRect:imageFrame];
tempImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return tempImage;
}
这样就可以修改选中状态和普通状态下的TabBarItem 图片的大小 ,是不是很简单呢,不足之处,还请大家多多指教
iOS 使用系统的UITabBarController 修改展示的图片大小的更多相关文章
- 修改jpg的图片大小
using System.Drawing.Imaging; public void ResizePic(string oldFilePath, int thumbnailImageWidth, int ...
- iOS开发UI篇—UITabBarController简单介绍
iOS开发UI篇—UITabBarController简单介绍 一.简单介绍 UITabBarController和UINavigationController类似,UITabBarControlle ...
- [转帖]迅为4412开发板最小linux系统的存储空间修改
本文转自迅为论坛:http://www.topeetboard.com 最小linux系统的存储空间修改以修改成 1G 存储空间为例来修改,如果需要改成其他大小的存储空间,参照此方法修改即可. 首先连 ...
- [分享]运维分享一一阿里云linux系统mysql密码修改脚本
[分享]运维分享一一阿里云linux系统mysql密码修改脚本 大象吃豆子 级别: 小白 发帖 12 云币 27 加关注 写私信 只看楼主 更多操作楼主 发表于: 2014-09-3 ...
- ios UIWebView截获html并修改便签内容(转载)
ios UIWebView截获html并修改便签内容 博客分类: iphone开发iphone开发phoneGap uiwebviewstringByEvaluatingJavaScriptFromS ...
- IOS UIWebView截获html并修改便签内容,宽度自适应
需求:混合应用UIWebView打开html后,UIWebView有左右滚动条,要去掉左右滚动效果: 方法:通过js截获UIWebView中的html,然后修改html标签内容: 实例代码: 服 ...
- iOS开发UI篇—UITabBarController生命周期(使用storyoard搭建)
iOS开发UI篇—UITabBarController生命周期(使用storyoard搭建) 一.UITabBarController在storyoard中得搭建 1.新建一个项目,把storyb ...
- ios UIWebView截获html并修改便签内容
需求:混合应用UIWebView打开html后,UIWebView有左右滚动条,要去掉左右滚动效果: 方法:通过js截获UIWebView中的html,然后修改html标签内容: 实例代码: 服务器端 ...
- iOS 捕获系统外异常
iOS 捕获系统外异常 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致"创作公用协议 转载请保留此句:太 ...
随机推荐
- Table布局的优缺点
总结 Table布局的缺点是比其它html标记占更多的字节,会阻挡浏览器渲染引擎的渲染顺序,会影响其内部的某些布局属性的生效,优点就是用table做表格是完全正确的 Tables的缺点 1.Table ...
- JSP中request对象常用方法汇总
setAttribute(String name,Object):设置名字为name的request的参数值 getAttribute(String name):返回由name指定的属性值 getAt ...
- [LC] 255. Verify Preorder Sequence in Binary Search Tree
Given an array of numbers, verify whether it is the correct preorder traversal sequence of a binary ...
- 吴裕雄--天生自然python学习笔记:python 用pygame模块检测键盘事件和鼠标事件
用户可通过键盘输入来操控游戏中角色的运动,取得键盘事件的方法有以下两种 : 常用的按键与键盘常数对应表 : 按下右箭头键,蓝色小球会 向 右移动:按住右箭头键不放 , 球体会快速 向 右移 动, 若到 ...
- PAT甲级——1009 Product of Polynomials
PATA1009 Product of Polynomials Output Specification: For each test case you should output the produ ...
- 用@font-face应用自定义字体
@font-face格式 @font-face { font-family: <YourWebFontName>; src: <source> [<format>] ...
- bzoj1076 奖励关(概率dp)(状态压缩)
BZOJ 1076 [SCOI2008]奖励关 Description 你正在玩你最喜欢的电子游戏,并且刚刚进入一个奖励关.在这个奖励关里,系统将依次随机抛出k次宝物,每次你都可以选择吃或者不吃(必须 ...
- mysql挖掘与探索------第2章 索引1-2 全文索引FULLTEXT
A 显示表的所有索引: show INDEX from phphi_article; B删除索引:alter table phphi_article drop INDEX fullwords; C添加 ...
- MOOC(7)- case依赖、读取json配置文件进行多个接口请求-执行测试用例(16)
执行测试用例 # -*- coding: utf-8 -*- # @Time : 2020/2/12 22:56 # @File : run_test_16.py # @Author: Hero Li ...
- stress命令安装
一.stress(cpu) stress是一个linux下的压力测试工具,专门为那些想要测试自己的系统,完全高负荷和监督这些设备运行的用户. 下载地址http://people.seas.harvar ...