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处理的更多相关文章
随机推荐
- Git的一些基本概念
Git的一些基本概念 设置自己的用户名和邮箱git config –global user.name "Your Name"git config –global user.emai ...
- Oracle删除表、字段之前判断表、字段是否存在
这篇文章主要介绍了Oracle删除表.字段之前判断表.字段是否存在的相关资料,需要的朋友可以参考下 在Oracle中若删除一个不存在的表,如 “DROP TABLE tableName”,则会提示: ...
- CentOS搭建OpenVPN服务(简易版)
OpenVPN服务端配置 1. 安装OpenVPN软件包 默认的Centos软件源里面没有OpenVPN的软件包,我们可以添加rpmforge的repo,从而实现yum安装openvpn 针对Cent ...
- BZOJ 1682: [Usaco2005 Mar]Out of Hay 干草危机
Description 牛们干草要用完了!贝茜打算去勘查灾情. 有N(2≤N≤2000)个农场,M(≤M≤10000)条双向道路连接着它们,长度不超过10^9.每一个农场均与农场1连通.贝茜要走遍每一 ...
- 常用的python模块
http://tiankonghaikuo1000.blog.163.com/blog/static/18231597200812424255338/ adodb:我们领导推荐的数据库连接组件bsdd ...
- SpringMVC可以配置多个拦截后缀*.html和.do等
一个servlet可以配置多个servlet-mapping, 因此在xml文件中我们可以这样配置: <!-- springmvc配置 --> <servlet> <se ...
- TYPEC 接口芯片CC逻辑原理与必要性
USB Type-C凭借其自身强大的功能,在Apple,Intel,Google等厂商的强势推动下,必将迅速引发一场USB接口的革命,并将积极影响我们日常生活的方方面面.为了能够使自己的设备兼容这些接 ...
- IPv6 tutorial 1 Get started now
https://4sysops.com/archives/ipv6-part-1-get-started-now/ You’ve probably heard the news that the In ...
- 我的第一个Hibernate程序
1.建表建序列(所用数据库为Oracle,数据库名为XE,创建用户hibernate,密码为123456) conn system/manager; ; grant connect to hibern ...
- 结构体dict_table_t
typedef struct dict_table_struct dict_table_t; /** Data structure for a database table. Most fields ...