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处理的更多相关文章
随机推荐
- jQuery UI dialog 的使用
今天用到了客户端的对话框,把 jQuery UI 中的对话框学习了一下. 准备 jQuery 环境 首先,我们创建一个按钮,点击这个按钮的时候,将会弹出一个对话框. 1 <input type= ...
- Linux的直接I/O机制
转自Linux的直接I/O机制 对于传统的操作系统来说,普通的 I/O 操作一般会被内核缓存,这种 I/O 被称作缓存 I/O.本文所介绍的文件访问机制不经过操作系统内核的缓存,数据直接在磁盘和应用程 ...
- 关于PIL库的一些概念
关于PIL库的一些概念 pil能处理的图片类型pil可以处理光栅图片(像素数据组成的的块). 通道一个图片可以包含一到多个数据通道,如果这些通道具有相同的维数和深度,Pil允许将这些通道进行叠加 模式 ...
- mysql通过frm+ibd文件还原data
此方法只适合innodb_file_per_table = 1 当误删除ibdata 该怎么办? 如下步骤即可恢复: 1.准备工作 1)准备一台纯洁的mysql环境[从启动到现在没有 ...
- Maven如何手动添加jar包到本地Maven仓库
Apache Maven,是一个软件(特别是Java软件)项目管理及自动构建工具,由Apache软件基金会所提供.基于项目对象模型(缩写:POM)概念,Maven利用一个中央信息片断能管理一个项目的构 ...
- POJ 2289 Jamie's Contact Groups & POJ3189 Steady Cow Assignment
这两道题目都是多重二分匹配+枚举的做法,或者可以用网络流,实际上二分匹配也就实质是网络流,通过枚举区间,然后建立相应的图,判断该区间是否符合要求,并进一步缩小范围,直到求出解.不同之处在对是否满足条件 ...
- [Unity菜鸟] Mecanim 系统遇到的问题
1. 给角色添加一个Animator组件和New State,运行后,摆出这种奇怪的姿势 这是因为没有把动画片段赋给New State,可以看到此时的New State为空,把Idle片段拖进去就好了 ...
- datetime 和 smalldatetime
用于表示某天的日期和时间的数据类型. datetime 和 smalldatetime 表示某天的日期和时间. 数据类型 范围 精确度 datetime 1753 年 1 月 1 日到 9999 年 ...
- [译]GotW #6b Const-Correctness, Part 2
const和mutable对于书写安全代码来说是个很有利的工具,坚持使用它们. Problem Guru Question 在下面代码中,在只要合适的情况下,对const进行增加和删除(包括 ...
- windows平台下VLC2.0.5编译
windows平台下VLC2.0.5编译说明 时隔一年多,又要搞流媒体了,不过这次是要做流媒体服务器. 暂时决定使用vlc+ffmpeg+live555,虽然听有些前辈说这个组合的性能较差,只能作为学 ...