詳解iPhone應(yīng)用中剪切技巧
作者:佚名
本文介紹的是詳解iPhone應(yīng)用中剪切技巧,主要介紹了iphone中的應(yīng)用技巧,先來看詳細(xì)內(nèi)容。
詳解iPhone應(yīng)用中剪切技巧是本文呢要介紹的內(nèi)容,主要介紹了iphone中的應(yīng)用技巧,內(nèi)容不多,我們吸納來看詳細(xì)內(nèi)容。iPhone應(yīng)用中的剪切技巧列表。
1.獲取圖形上下文
2.構(gòu)造剪切的路徑(形狀)
3.構(gòu)建剪切區(qū)域
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];
截取屏幕圖片
- //創(chuàng)建一個基于位圖的圖形上下文并指定大小為CGSizeMake(200,400)
- UIGraphicsBeginImageContext(CGSizeMake(200,400));
- //renderInContext 呈現(xiàn)接受者及其子范圍到指定的上下文
- [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
- //返回一個基于當(dāng)前圖形上下文的圖片
- UIImage *aImage = UIGraphicsGetImageFromCurrentImageContext();
- //移除棧頂?shù)幕诋?dāng)前位圖的圖形上下文
- UIGraphicsEndImageContext();
- //以png格式返回指定圖片的數(shù)據(jù)
- imageData = UIImagePNGRepresentation(aImage);
小結(jié):詳解iPhone應(yīng)用中剪切技巧的內(nèi)容介紹完了,希望本文對你有所幫助。
責(zé)任編輯:zhaolei
來源:
博客園