Reputation: 849
Do you have any idea about adding constraints to CALayer programmatically?
Upvotes: 0
Views: 1869
Reputation: 4323
There are several ways to constraint a CALayer, although you cannot use NSLayoutConstraints. Most flexible way is to sub-class CALayer and override - (void)layoutSublayers;
. Then you can position and size your content however you want. A simpler and more limited approach is to set the layer's contentsGravity
property. With this you can set the layer to (for example) always position content in a corner, or do aspect fill.
Read more about contentsGravity.
Upvotes: 3
Reputation: 717
Constraints is a part of AutoLayout system of UIVIew, so no you cant do this
Upvotes: 0