Custom UIToolbar resize with animation

2019-09-02 16:17发布

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条回答
三岁会撩人
2楼-- · 2019-09-02 16:51

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
];
查看更多
登录 后发表回答