Custom UIToolbar resize with animation

2019-09-02 16:49发布

问题:

i'm using this piece of code to resize my custom UIToolbar to change width property

[UIView animateWithDuration:0.3 delay:0.3 options:0 animations:^{
    self.navToolbar.frame=CGRectMake(0, 0, 200, 30);
} completion:nil];

the code above, change width correctly but without animation, could anyone tell me why?

Thanks

回答1:

UIViewAnimationOptionLayoutSubviews (iOS > 4.0) should fix the problem when the size change is not being animated.

[UIView animateWithDuration:0.3 
        delay:0.3 
        options:UIViewAnimationOptionLayoutSubviews 
        animations:^{
        self.navToolbar.frame=CGRectMake(0, 0, 200, 30);
        }
       completion:nil
];