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) 本文遵循"署名-非商业用途-保持一致"创作公用协议 转载请保留此句:太 ...
随机推荐
- AI大火之下智能手机行业能适应这一风口吗?
今年智能手机行业的变化,实在是让人摸不到头脑.一方面是智能手机厂商依然在拿出各种具有噱头的产品,仿佛整个市场还依然热火朝天.但在另一方面,智能手机出货量却出现大幅下滑.据中国信息通信研究院发布的数据显 ...
- Solving ordinary differential equations I(Nonstiff Problems),Exercise 1.2:A wrong solution
(Newton 1671, “Problema II, Solutio particulare”). Solve the total differential equation $$3x^2-2ax+ ...
- JavaWeb过滤器(Filter)
参考:https://blog.csdn.net/yuzhiqiang_1993/article/details/81288912 原理: 一般实现流程: 1.新建一个类,实现Filter接口2.实现 ...
- FIT AP和FAT AP的区别
1.Fat模式是传统的WLAN组网方案,无线AP本身承担了认证终结.漫游切换.动态密钥产生等复杂功能,相对来说AP的功能较重,因此称为Fat AP. 2.Fit模式是新兴的一种WLAN组网模式,其相 ...
- Docker系列二: docker常用命令总结
https://docs.docker.com/reference/ 官方命令总结地址 容器生命周期管理 1.docker run 创建一个新的容器并运行一个命令 docker run [optio ...
- django框架进阶-解决跨域问题
####################################### """ 一.为什么会有跨域问题? 是因为浏览器的同源策略是对ajax请求进行阻拦了,但是不 ...
- POJ 3617 Best Cow Line 字典序最小
#include<cstdio> #include<iostream> #include<algorithm> #include<queue> #inc ...
- python之time模块和hashlib模块
一.time模块 import time print(time.strftime('%Y-%m-%d %H:%M:%S'))#获取当前的格式化时间,time.strftime(format) prin ...
- file_get_contents为何无法采集某些压缩过的网站
有些网站直接用file_get_contents就能采集, 但是有些不行. 于是可以在网址前加入 'compress.zlib://‘ $url = 'compress.zlib://' . 'htt ...
- numpy矩阵运算--矩阵乘法
1)元素对应相乘,使用 multiply 函数或 * 运算符来实现 a = np.array([2,2,2])b = np.array([3,3,3]) c1 = a*a c1 array([4, 4 ...