我正在使用以下代码在iOS设备上更改方向时设置视图。这可以给我我想要的形状(更宽和相同的高度),但是当改变方向时动画是跳跃的。如果我隐藏setFrame
代码,动画非常流畅,但当然形状不会变宽。我尝试添加变换,但到目前为止,它以不合需要的方式扭曲了视图的形状(因为视图包含带圆角的复杂绘制形状等)。
[myView setFrame:CGRectMake(0, 0, self.view.bounds.size.width-20, 170)];
[myView setNeedsDisplay];
CGPoint viewCenter = CGPointMake((myView.frame.size.width/2)+someNum (self.view.bounds.size.height-(someOtherNum/2)-anotherNum));
myView.center = viewCenter;
//quick unsuccessful test to see if transforms would work:
//myView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.5, 1);
对此有何帮助?有没有办法在没有动画的情况下获得我的结果?
感谢阅读!
答案 0 :(得分:1)
你试过UIViewAnimation吗?
[UIView animateWithDuration:0.2 animations:^{
[myView setFrame:CGRectMake(0, 0, self.view.bounds.size.width-20, 170)];
[myView setNeedsDisplay];
CGPoint viewCenter = CGPointMake((myView.frame.size.width/2) + someNum
(self.view.bounds.size.height-(someOtherNum/2)-anotherNum));
myView.center = viewCenter;
}];