小编Dav*_*mer的帖子

如何从3D转换的UIImageView创建/渲染UIImage?

将3d变换应用到UIImageView.layer之后,我需要将生成的"视图"保存为新的UIImage ...起初看起来像一个简单的任务:-)但到目前为止没有运气,搜索没有出现任何线索:-(所以我希望有人能够指出我正确的方向.

一个很简单的iPhone项目,请点击这里.

谢谢.

- (void)transformImage {
    float degrees = 12.0;
    float zDistance = 250;
    CATransform3D transform3D = CATransform3DIdentity;
    transform3D.m34 = 1.0 / zDistance; // the m34 cell of the matrix controls perspective, and zDistance affects the "sharpness" of the transform
    transform3D = CATransform3DRotate(transform3D, DEGREES_TO_RADIANS(degrees), 1, 0, 0); // perspective transform on y-axis
    imageView.layer.transform = transform3D;
}

/* FAIL : capturing layer contents doesn't get the transformed image -- just the original

CGImageRef newImageRef = (CGImageRef)imageView.layer.contents;

UIImage *image …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch core-animation

14
推荐指数
2
解决办法
8932
查看次数

标签 统计

cocoa-touch ×1

core-animation ×1

iphone ×1