在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
}];
}