首页 > ios 关于视图变大后子视图的问题

ios 关于视图变大后子视图的问题

如题
是这样的 比如我有一个uiview 上面有一个UIimageview和UIlabel 当我用[UIView animateWithDuration:0.2 animations:^{}];这个动画函数 将UIview变大 但是发现上面的UIimageview和UIlabel的视图并没有跟随变大,是不是只有取到UIview的子视图UIimageview和UIlabel做操作让其变大 这样的话就太麻烦了 比如 我UIview的子视图很多 那不是操作就更多了,有没有什么办法是只需要改变UIview的大小其他的子视图跟随变大的办法呢?


用最简单的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"];

没有这种功能吧


http://blog.csdn.net/wxs0124/article/details/40296009 刚好看看到这篇 希望有帮助


如果用自动布局的话,设置子控件到父控件的距离,调用LayoutIfNeed重新布局

【热门文章】
【热门文章】