在layoutSubviews中,我將子視圖佈局到合適的位置,並且其中一些應用了一些轉換。現在我想在這個子視圖上製作可重複的縮放動畫來吸引注意力。但是,當我使用[UIView animate ....]啓動動畫時,通過更改transform屬性觸發的layoutSubviews方法(與動畫衝突(它覆蓋變換和動畫未播放))。iOS:在不調用佈局的情況下動畫子視圖子視圖
有沒有什麼好的方法(沒有布爾標誌)來處理這種行爲?
例子:
- (void)layoutSubviews {
[super layoutSubviews];
myChildView.transform = CGAffineTransformMake....;
}
- (void)animate {
CGAffineTransform originalTransform = myChildView.transform;
[UIView animateWithDuration:0.1f
delay:0.0f
options:UIViewAnimationOptionAutoreverse
animations:^{
[UIView setAnimationRepeatCount:4];
//next line of code produce calling layoutSubviews
myChildView.transform = CGAffineTransformMakeScale(1.15f, 1.15f);
} completion:^(BOOL finished){
myChildView.transform = originalTransform;
//after this also called layoutSubviews
}];
}