我看过很多关于截图的问题和答案,我知道该怎么做,这不是我的问题,这是我的代码:
- (void)takeScreenShot
{
//UIGraphicsBeginImageContextWithOptions(CGSizeMake(320, 340), YES, 0.);
UIGraphicsBeginImageContext(CGSizeMake(320, 480));
[self.view.window.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
如何拍摄圆形屏幕而不是 320x480 方框?
你可以试试这个:
- (UIImage *)takeRoundedScreenShotCGPoint)center
{
float cornerRadius = self.view.window.layer.cornerRadius;
CGAffineTransform savedTransform = self.view.window.transform;
UIGraphicsBeginImageContext(CGSizeMake(320, 320));
self.view.window.layer.cornerRadius = 160;
self.view.window.clipsToBounds = YES;
self.view.window.transform = CGAffineTransformMakeTranslation(-(center.x-160), -(center.y-160));
[self.view.window.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
self.view.window.transform = savedTransform;
self.view.window.layer.cornerRadius = cornerRadius.
return viewImage;
}
关于objective-c - 如何拍摄圆形屏幕截图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13007512/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |