Sag*_*... 1 cocoa-touch objective-c ios
我正在尝试生成具有子视图的UIView的屏幕截图CATransform3DMakeRotation.屏幕截图已生成,但不包含"旋转".
是否有可能实现这一目标?
实际观点:

ScreenShot图像

使用以下调用水平翻转视图...
currentView.layer.transform = CATransform3DConcat(currentView.layer.transform,CATransform3DMakeRotation(M_PI, 0.0, 1.0, 0.0f));
Run Code Online (Sandbox Code Playgroud)
拍摄屏幕截图的代码
+ (UIImage *) imageWithView:(UIView *)view
{
CGSize screenDimensions = view.bounds.size;
// Create a graphics context with the target size
// (last parameter takes scale into account)
UIGraphicsBeginImageContextWithOptions(screenDimensions, NO, 0);
// Render the view to a new context
CGContextRef context = UIGraphicsGetCurrentContext();
[view.layer renderInContext:context];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}
Run Code Online (Sandbox Code Playgroud)
"renderInContext"仅适用于仿射变换.因此,将3D变换转换为仿射变换
currentView.layer.affineTransform = CATransform3DGetAffineTransform(CATransform3DConcat(currentView.layer.transform,CATransform3DMakeRotation(M_PI, 0.0, 1.0, 0.0f)));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1986 次 |
| 最近记录: |