Abh*_*gsk 1 ipad uiinterfaceorientation ios
我正在开发一款只适用于风景的应用.在那个应用程序中,我有一个功能,截取该特定屏幕的截图.我已经实现了这段代码
UIGraphicsBeginImageContext(self.view.window.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImageView *imageView = [[UIImageView alloc] init];
imageView.image = UIGraphicsGetImageFromCurrentImageContext();;
imageView.transform = CGAffineTransformMakeRotation(3.0 * M_PI / 2.0);
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(imageView.image, nil, nil, nil);
Run Code Online (Sandbox Code Playgroud)
使用此代码,我以纵向模式获取我的应用程序的屏幕截图.我希望它在横向模式下.
不要添加window.如果添加它,则上下文大小错误.
// Just use self.view.bounds.size is OK
UIGraphicsBeginImageContext(self.view.bounds.size);
Run Code Online (Sandbox Code Playgroud)