Animate intrinsicContentSize changes

后端 未结 6 810
借酒劲吻你
借酒劲吻你 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:21

    In the code below, intrinsic class is the class that has just changed it's size on changing a variable. To animate the intrinsic class only use the code below. If it impacts other objects higher up the view hierarchy then replace self.intrinsic class with the top level view for setNeedsLayout and layoutIfNeeded.

    [UIView animateWithDuration:.2 animations:^{
            self.intrinsicClass.numberOfWeeks=8;
            [self.intrinsicClass setNeedsLayout];
            [self.intrinsicClass layoutIfNeeded];
        }];
    

提交回复
热议问题