Animate intrinsicContentSize changes

后端 未结 6 816
借酒劲吻你
借酒劲吻你 2021-01-30 08:15

I have a UIView subclass that draws a circle whose radius changes (with nice bouncy animations). The view is deciding the size of the circle.

I want this UIView subclass

6条回答
  •  天涯浪人
    2021-01-30 09:13

    invalidateIntrinsicContentSize works well with animations and layoutIfNeeded. The only thing you need to consider is, that changing the intrinsic content size invalidates the layout of the superview. So this should work:

    [UIView animateWithDuration:0.2 animations:^{
        [self invalidateIntrinsicContentSize];
        [self.superview setNeedsLayout];
        [self.superview layoutIfNeeded];
    }];
    

提交回复
热议问题