sudo rm -rf
sudo rm -rf

Reputation: 29524

CGAffineTransformation set the anchor?

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 where 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?

Upvotes: 1

Views: 4724

Answers (2)

Sascha
Sascha

Reputation: 5973

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.

Upvotes: 4

Lou Franco
Lou Franco

Reputation: 89232

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

Upvotes: 1

Related Questions