I have created a subclass of UIView that has this property
@propert (nonatomic, copy) NSArray *tags;
The tags array contains a list of strings that the view should display. The view should adjust its size according to the number of tags it displays. Who should be responsible for adjusting the view's size?
Superview is responsible for placement of subviews. However in certain scenarios the size of subview can vary than the static size specified by superview. In such cases superview can be relayout. Each subview is then queried for sizeThatFits:
to return the precise size.
So, override sizeThatFits:
method in subview and return the dynamic size that is required by the view to precisely fit its content/subviews.
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.