Applying scaling and rotation on a view using CGAffineTransform

前端 未结 4 729
轮回少年
轮回少年 2021-01-11 10:45

So I need to apply some scaling and some rotation to a view (I do this using gestures), so for each gesture I update the current scalling and rotation values with something

4条回答
  •  一向
    一向 (楼主)
    2021-01-11 11:29

    You should start from your current transformed state and apply transformation which is expected. Also you can have a look at CGAffineTransformConcat, it will make it a single transform before applying.

    CGAffineTransform transform = yourView.transform;
    transform = CGAffineTransformConcat(CGAffineTransformScale(transform,  self.scaleWidth, self.scaleHeight),
                                        CGAffineTransformRotate(transform, self.rotationAngle));
    yourView.transform = transform;
    

    Hope it helps!

提交回复
热议问题