Azerue
Azerue

Reputation: 368

CGAffineTransform does not effect autolayout

recently I have been working with CGAffineTransform and CATransform3D on views and layers. When I apply transformation at layer level and especially on view level, shouldn't autolayout updates the frames of related views. For example, consider following layout |H:[ViewA]-[ViewB]|. If I apply transformation on just ViewA.

//We can either
    ViewA.transform = CGAffineTransformMakeScale(1.5, 1.5) 
    ViewA.layer.transform = CATransform3DMakeScale(1.5, 1.5, 1.0)

shouldn't ViewB auto adjust it rect since ViewA height, width or position has changed after transformation. I also tried calling

self.view.layoutIfNeeded()

Upvotes: 2

Views: 2143

Answers (1)

Krumelur
Krumelur

Reputation: 33048

Transformations don't affect the Frame or Bounds of a view or the frame will be in an undefined state. To illustrate that: image you have a rectangular view with a frame of X:10, Y:10, W:100, H:100 and you rotate that by 45 degrees...what should the frame be?

From Apple's docs about the transformation:

If this property is not the identity transform, the value of the frame property is undefined and therefore should be ignored.

This explains why AutoLayout does not perform any updates.

Upvotes: 1

Related Questions