2

In my iOS app I want to change the anchorPoint of a CALayer so that I can perform a specific rotation (from a corner). I'm working with a UIImageView created in interface builder.

I'm aware that changing the anchorPoint of the layer will affect the frame of both the layer and the view and therefore the layer's position needs to be updated. So I used the solution explained here.

Here's the view before changing anything:

enter image description here

self.square.layer.anchorPoint : {0.5, 0.5}
self.square.layer.position : {125, 125}
self.square.layer.frame : {{0, 0}, {250, 250}}
self.square.frame : {{0, 0}, {250, 250}}

and here's how it look after setting the new anchorPoint and position (by using this solution)

enter image description here

self.square.layer.anchorPoint : {0, 1}
self.square.layer.position : {0, 250}
self.square.layer.frame : {{0, 0}, {250, 250}}
self.square.frame : {{0, 0}, {250, 250}}

On the screenshots square is a UIImageView without any image and with a purple background but the behaviour is the same when I use a UIView. I don't get why the view is moved but the printed frame is still the same. How's that possible? What am I missing?

EDIT:

I was using autolayout. After disabling it all is fine but that's not handy. How can I achieve this without disabling autolayout ?

Community
  • 1
  • 1
Alexis
  • 16,629
  • 17
  • 62
  • 107
  • What is the effect that you want to achieve? – guardabrazo Jun 23 '14 at 12:46
  • 3
    Well the view should stay where it is but when I would apply a rotation it should rotate around the left bottom corner instead of around the center of the view. – Alexis Jun 23 '14 at 13:36

0 Answers0