如题
是这样的 比如我有一个uiview 上面有一个UIimageview和UIlabel 当我用[UIView animateWithDuration:0.2 animations:^{}];这个动画函数 将UIview变大 但是发现上面的UIimageview和UIlabel的视图并没有跟随变大,是不是只有取到UIview的子视图UIimageview和UIlabel做操作让其变大 这样的话就太麻烦了 比如 我UIview的子视图很多 那不是操作就更多了,有没有什么办法是只需要改变UIview的大小其他的子视图跟随变大的办法呢?
巴扎黑2017-04-17 17:59:00
用最简单的scale变换就行。
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
animation.fromValue = @(1.0);
animation.toValue = @(2.0);
animation.duration = 2.0f;
animation.repeatCount = 1;
[self.button.layer addAnimation:animation forKey:@"ScaleAnimation"];
如果你平常用pop的话,就是这样:
POPBasicAnimation *animation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewScaleXY];
animation.toValue = [NSValue valueWithCGPoint:CGPointMake(2.0, 2.0)];
animation.duration = 3.0f;
[self.button pop_addAnimation:animation forKey:@"ScaleAnimation"];