I have a UIView
subclass (to deal with drag and drop) and with Interface Build I added two subviews: an UIImageView
and an UILabel
.
Both have constraints:
UIImageView
border match the superview borders in order to fill all the available space. UILabel
is centered vertical and horizontally.
Here you can see the three (superview background is green).
My problem comes when I animate a frame change in the superview. The superview seems fine, but its subviews go crazy.
Here you can see it (ignore the brown square, is from another view)
As you can see, subviews "fall" from the superview, despite I call updateConstraints
on every subview.
I know it is a bad practice to mix AutoLayout with setFrame, but is the only way I know to do it.
Thanks
Thanks to the comments I made some changes.
1) Change the superview (the green one) with the UIImageView.
2) Remove the UILabel and use a CATextLayer to place the text, using this answer to center the text vertically in front of the UIImageView.
And now it works fine. Thanks for the help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.