詳解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應用中剪下技巧的內容介紹完了,希望本文對你有所協助。