子View中使用AutoLayout后,在父View中如果使用animateWithDuration進(jìn)行動畫處理,子View的動畫效果生效,但是子View中的元素不會產(chǎn)生動畫效果脊另。
解決方法,需要在執(zhí)行animateWithDuration中調(diào)用子View的layoutIfNeeded
[UIView animateWithDuration:2 animations:^{
CGRect rect = self.loginAlertV.frame;
rect.size.width = SCREEN_WIDTH - 24 - 40 - 24;
self.loginAlertV.frame = rect;
[self.loginAlertV layoutIfNeeded];
} completion:^(BOOL finished) {}];
類似這樣