-
//获得屏幕图像
-
-
(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 抓图实现
最新推荐文章于 2021-05-28 01:51:00 发布