简体   繁体   中英

iOS — How to scale the UIView with left top point?

I want to fix a point (left top point) and scale (zoom out) the UIView according to the point

like this image

在此输入图像描述

Now I use self.transform = CGAffineTransformMakeScale( 0.7 , 0.7); to scale the UIView , But it only can scale the UIView according to the center point 在此输入图像描述

Edit

I try to use set anchorPoint with (0,0) but the view position be wrong

在此输入图像描述

使用anchorPoint属性:

self.layer.anchorPoint = CGPointMake(0.0, 0.0);

尝试设置图层container!.layer.anchorPoint = CGPoint(x: 0, y: 0) anchorPoint container!.layer.anchorPoint = CGPoint(x: 0, y: 0)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM