詳解iPhone應用中剪切技巧
作者:佚名
本文介紹的是詳解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];
截取屏幕圖片
- //創建一個基于位圖的圖形上下文并指定大小為CGSizeMake(200,400)
- UIGraphicsBeginImageContext(CGSizeMake(200,400));
- //renderInContext 呈現接受者及其子范圍到指定的上下文
- [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
- //返回一個基于當前圖形上下文的圖片
- UIImage *aImage = UIGraphicsGetImageFromCurrentImageContext();
- //移除棧頂的基于當前位圖的圖形上下文
- UIGraphicsEndImageContext();
- //以png格式返回指定圖片的數據
- imageData = UIImagePNGRepresentation(aImage);
小結:詳解iPhone應用中剪切技巧的內容介紹完了,希望本文對你有所幫助。
責任編輯:zhaolei
來源:
博客園