UIImageC处理
UIImageC处理
1、等比缩放
- - (UIImage *) scaleImage:(UIImage *)image toScale:(float)scaleSize {
- UIGraphicsBeginImageContext(CGSizeMake(image.size.width * scaleSize, image.size.height * scaleSize);
- [image drawInRect:CGRectMake(0, 0, image.size.width * scaleSize, image.size.height * scaleSize)];
- UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
- return scaledImage;
- }
2、自定义大小
- - (UIImage *) reSizeImage:(UIImage *)image toSize:(CGSize)reSize {
- UIGraphicsBeginImageContext(CGSizeMake(reSize.width, reSize.height));
- [image drawInRect:CGRectMake(0, 0, reSize.width, reSize.height)];
- UIImage *reSizeImage = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
- return reSizeImage;
- }
3、处理某个特定的view
只要是继承UIView的object 都可以处理
必须先import QuzrtzCore.framework
- -(UIImage*) captureView:(UIView *)theView {
- CGRect rect = theView.frame;
- UIGraphicsBeginImageContext(rect.size);
- CGContextRef context = UIGraphicsGetCurrentContext();
- [theView.layer renderInContext:context];
- UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
- return img;
- }
4、存储图片
4.1、存储到app的文件里
把要处理的图片以image.png的名字存储到app home地下的Document目录中
- NSString *path = [[NSHomeDirectory()stringByAppendingPathComponent:@"Documents"]stringByAppendingPathComponent:@"image.png"];
- [UIImagePNGRepresentation(image) writeToFile:pathatomically:YES];
4.2、存储到手机的图片库中
- CGImageRef screen = UIGetScreenImage();
- UIImage* image = [UIImage imageWithCGImage:screen];
- CGImageRelease(screen);
- UIImageWriteToSavedPhotosAlbum(image, self, nil, nil);
获取当前app的名称和版本号
- NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
- // app名称
- NSString *name = [infoDictionary objectForKey:@"CFBundleDisplayName"];
- // app版本
- NSString *version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
- // app build版本
- NSString *build = [infoDictionary objectForKey:@"CFBundleVersion"];
UILabel根据text自动调整大小
- label.text = @"**********";
- CGRect frame = label.frame;
- frame.size.height = 10000; // 设置一个很大的高度
- label.frame = frame;
- [label sizeToFit];
- frame.size.height = label.frame.size.height;
- label.frame = frame;
直接拨打有分机号的电话
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://01011112222,3333"]];
参考:http://apluck.iteye.com/blog/1418640#
UIImageC处理的更多相关文章
随机推荐
- js点击图片显示在左边大图
<div class="imgbox cf"> <img src="temp/pic2.jpg" alt="" cl ...
- w3c subscribe
http://www.w3.org/html/ig/zh/ http://blog.csdn.net/spring21st/article/details/6126537 http://www.w3c ...
- Ubuntu下与菜单和图标相关的几个文件夹
转自UBUNTU下与菜单和图标相关的几个文件夹 /usr/share/icons 系统图标文件夹 /usr/share/applications 系统菜单文件夹,要在左上角的应用程序菜单中添加一项 ...
- icon在线编辑和查找工具
1.www.iconpng.com 2.在线编辑http://www.ico.la/ 3.小图标查找 http://icomoon.io/app/ 4.20个免费的psd http://www.osc ...
- 查看linux系统的版本
1. 查看内核版本命令: 1) [root@SOR_SYS ~]# cat /proc/version Linux version 2.6.18-238.el5 (mockbuild@x86-012. ...
- UIcollectionView的使用(首页的搭建4)
2.5 头部视图
- RAM云存储已经出现了,就是特别贵
据说bat有这种全内存的服务器集群, RAM的问题是,容量上去了就会很费电,而且不方便做持久化,并且成本也不低,一般只能作为缓存.内存数据库,给bat.12306这种高富帅用 也有提供内存云存储的服务 ...
- 二维图形的矩阵变换(二)——WPF中的矩阵变换基础
原文:二维图形的矩阵变换(二)--WPF中的矩阵变换基础 在前文二维图形的矩阵变换(一)——基本概念中已经介绍过二维图像矩阵变换的一些基础知识,本文中主要介绍一下如何在WPF中进行矩阵变换. Matr ...
- 【Linux安全】防止任意用户使用 su 切换到 root
防止任意用户使用 su 切换到 root 在终端中输入下列命令 vim /etc/pam.d/su (按 i 进行编辑,qw 保存并推出) 在头部加入行: auth required pam_whee ...
- .Net remoting, Webservice,WCF,Socket区别
传统上,我们把计算机后台程序(Daemon)提供的功能,称为"服务"(service).比如,让一个杀毒软件在后台运行,它会自动监控系统,那么这种自动监控就是一个"服务& ...