CGAffineTransform and scaling to center of the image

后端 未结 3 897
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-12 02:16

I started studying objective-c using the iPhone and iPad apps for Absolute Beginners by Rory Lewis book but i got stuck on the 5th chapter.

I want to make a

3条回答
  •  天涯浪人
    2021-01-12 02:57

    Old question... but just in case others come looking:

    The CGAffineTransform acts (rotates, scales) around an anchorPoint.

    If you are sizing to 0, 0 then your anchor point is set to 0, 0. If you want it to size to a different point, such as the center of the image, you need to change the anchor point.

    The anchor is part of a layer

    So if you have a UIImageView called imageview, you would make a call like this to set the anchor to the center of imageview:

    [imageview.layer setAnchorPoint:CGPointMake(0.5, 0.5)];
    

提交回复
热议问题