开发者

CGAffineTransformation set the anchor?

开发者 https://www.devze.com 2023-03-09 14:58 出处:网络
I\'m curious about something.In my app I\'m running an animation where a view is resized a little bit.I\'m creating the transform like this:

I'm curious about something. In my app I'm running an animation where a view is resized a little bit. I'm creating the transform like this:

CGAffineTransform resize = CGAffineTransformMakeScale(0.8, 0.8);

However, when I apply this transformation to my view and watch it run, it resizes from the top and shrinks towards the bottom. What I'm wanting is wh开发者_JS百科ere it resizes evenly on all sides and shrinks towards the center, as if an "anchor" point is in the center. You know what I'm saying? Is this possible?


First add the Quartz framework to your project and import the Quartz header

#import <QuartzCore/QuartzCore.h>

Then you can set the anchor point of your view like this

myView.layer.anchorPoint = CGPointMake(0, 0);

AnchorPoint points are values between 0 and 1. 0,0 is the top left corner on the iPhone.


First apply a CGAffineTransformMakeTranslation to move the origin to the center -- composite them into a single transform with CGAffineTransformConcat

0

精彩评论

暂无评论...
验证码 换一张
取 消