详解iPhone应用中剪切技巧

移动开发 iOS
本文介绍的是详解iPhone应用中剪切技巧,主要介绍了iphone中的应用技巧,先来看详细内容。

详解iPhone应用剪切技巧是本文呢要介绍的内容,主要介绍了iphone中的应用技巧,内容不多,我们吸纳来看详细内容。iPhone应用中的剪切技巧列表。

1.获取图形上下文

2.构造剪切的路径(形状)

3.构建剪切区域

4.贴上你的画 

// 1CGContextRef context = UIGraphicsGetCurrentContext();  
// 2CGRect bounds = CGRectMake(0.0f, 0.0f, SIDELENGTH, SIDELENGTH);  
 
CGMutablePathRef path = CGPathCreateMutable();CGPathAddEllipseInRect(path, NULL, bounds);  
// 3CGContextAddPath(context, path);CGContextClip(context);  
// 4[LOGO drawInRect:bounds]; 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.

截取屏幕图片

//创建一个基于位图的图形上下文并指定大小为CGSizeMake(200,400)  
UIGraphicsBeginImageContext(CGSizeMake(200,400));   
 
//renderInContext 呈现接受者及其子范围到指定的上下文  
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];  
     
 //返回一个基于当前图形上下文的图片  
 UIImage *aImage = UIGraphicsGetImageFromCurrentImageContext();  
   
 //移除栈顶的基于当前位图的图形上下文  
UIGraphicsEndImageContext();  
 
//以png格式返回指定图片的数据  
imageData = UIImagePNGRepresentation(aImage); 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.

小结:详解iPhone应用剪切技巧的内容介绍完了,希望本文对你有所帮助。

责任编辑:zhaolei 来源: 博客园
相关推荐

2011-08-10 17:37:00

iPhoneASIHTTPRequ

2011-08-12 14:33:06

iPhone缓存文件

2011-08-15 11:37:20

iPhone开发Mask

2011-08-03 17:18:58

iPhone UILabel UISlider

2011-08-09 14:08:51

iPhoneHTTP请求协议

2012-04-26 13:26:58

iPhone应用技巧

2011-08-08 14:57:46

iPhone Autoreleas Property

2010-02-05 18:04:21

C++剪切板

2011-08-11 13:35:28

iPhoneASIHTTPRequHTTP

2011-08-17 15:10:21

iPhone开发Web视图

2011-08-19 14:14:14

iPhone应用

2010-02-22 11:25:50

WCF DateSet

2011-07-27 11:14:37

iPhone UITableVie

2011-07-08 17:45:19

iPhone 文档

2011-08-17 15:19:38

iPhone应用数据

2011-08-12 10:04:24

iPhone开发视图

2011-07-26 09:41:23

iPhone xcode Mac OS X

2011-07-19 14:36:32

iPhone

2009-12-10 16:45:39

Linux操作系统

2011-08-02 17:14:41

iPhone应用 UITableVie
点赞
收藏

51CTO技术栈公众号