How do I use CATransform3D on a UIView to add a specific type of perspective?

 ̄綄美尐妖づ 提交于 2019-12-03 07:52:08

If you just want to skew, you don't need 3D transform. An affine transform will suffice.

-(void)drawRect:(CGRect)rect {
    CGContextRef ctx = UIGraphicsGetCurrentContext();
    CGAffineTransform transform = CGAffineTransformIdentity;
    transform.b = -0.1;
    transform.a = 0.9;
    CGContextConcatCTM(ctx,transform);
    // do drawing on the context
}

this is a modified copy&paste from a project which has a similar transform, but you may need to tune the parameters a and b. This will give a 1 in 9 rise from left to right (0.1/0.9), while condensing from left to right to 90% (0.9).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!