截图功能

2017-03-10  本文已影响0人  CHADHEA

//.h

+ (UIImage *)screenshotFrom:(UIView *)view frame:(CGRect)frame;

//.m

+ (UIImage *)screenshotFrom:(UIView *)view frame:(CGRect)frame {

UIGraphicsBeginImageContext(view.frame.size);

[view.layer renderInContext:UIGraphicsGetCurrentContext()];

UIImage      *image=UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

CGImageRef      cgImage=  CGImageCreateWithImageInRect([image CGImage], frame);

return [UIImage imageWithCGImage:cgImage];

}

谢谢阅读!

上一篇下一篇

猜你喜欢

热点阅读