- //获得屏幕图像
- -
(UIImage *)imageFromView: (UIView *) theView - {
-
-
UIGraphicsBeginImageCont ext(theView.frame.size); -
CGContextRef context = UIGraphicsGetCurrentCont ext(); -
[theView.layer renderInContext:context]; -
UIImage *theImage = UIGraphicsGetImageFromCu rrentImageContext(); -
UIGraphicsEndImageContex t(); -
-
return theImage; - }
-
- //获得某个范围内的屏幕图像
- -
(UIImage *)imageFromView: (UIView *) theView atFrame:(CGRect)r - {
-
UIGraphicsBeginImageCont ext(theView.frame.size); -
CGContextRef context = UIGraphicsGetCurrentCont ext(); -
CGContextSaveGState(context); -
UIRectClip(r); -
[theView.layer renderInContext:context]; -
UIImage *theImage = UIGraphicsGetImageFromCu rrentImageContext(); -
UIGraphicsEndImageContex t(); -
-
return theImage;//[self getImageAreaFromImage:theImage atFrame:r]; - }
IOS开发之—程序截图
最新推荐文章于 2023-06-28 10:56:27 发布