iPhone開發應用中抓圖程序案例實現
作者:佚名
iPhone開發應用中抓圖程序案例實現是本文要介紹的內容,主要是通過代碼來實現抓圖程序,具體實現過程,一起來看詳細代碼。
iPhone開發應用中抓圖程序案例實現是本文要介紹的內容,主要是通過代碼來實現抓圖程序,具體實現過程,一起來看詳細代碼。
- //獲得屏幕圖像
- - (UIImage *)imageFromView: (UIView *) theView
- {
- UIGraphicsBeginImageContext(theView.frame.size);
- CGContextRef context = UIGraphicsGetCurrentContext();
- [theView.layer renderInContext:context];
- UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
- return theImage;
- }
- //獲得某個范圍內的屏幕圖像
- - (UIImage *)imageFromView: (UIView *) theView atFrame:(CGRect)r
- {
- UIGraphicsBeginImageContext(theView.frame.size);
- CGContextRef context = UIGraphicsGetCurrentContext();
- CGContextSaveGState(context);
- UIRectClip(r);
- [theView.layer renderInContext:context];
- UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
- return theImage;//[self getImageAreaFromImage:theImage atFrame:r];
- }
小結:iPhone開發應用中抓圖程序案例實現的內容介紹完了,希望通過本文的學習能對你有所幫助!
責任編輯:zhaolei
來源:
互聯網