我有一个圆圈 UIView :
con=[[UIView alloc] initWithFrame:CGRectMake(self.frame.size.width-size-delta, y , size, size)];
con.layer.borderColor=[UIColor whiteColor].CGColor;
con.layer.borderWidth=1.0;
con.backgroundColor=[UIColor clearColor];
con.layer.cornerRadius=con.frame.size.width/2.0;
con.clipsToBounds=YES;
[self addSubview:con];
稍后我想将它的大小更改为更大的,但是当我这样做时,在动画开始时您会看到一些矩形,然后它又变回圆形。
我想要一个平面动画,当它的帧发生变化时它会保持为一个圆圈。
CGRect frm=startConfrm; //original frame of the circle
frm.size.width*=2;
frm.size.height*=2;
frm.origin.y=self.frame.size.height/2.0-frm.size.height/2.0;
[UIView animateWithDuration:1.5
delay:0.0
options: UIViewAnimationOptionCurveEaseInOut
animations:^{
con.frame=frm;
con.layer.cornerRadius=con.frame.size.width/2.0;
}
completion:^(BOOL finished){ }];
最佳答案
如果您只想缩放 View 大小,则可以使用以下代码。
[UIView animateWithDuration:2.0 animations:^{
con.transform = CGAffineTransformMakeScale(2, 2); // it will scale as double size
}completion:^(BOOL finished) {
// do whatever at animation completion
}
}];
要将 View 重置为正常大小,
con.transform = CGAffineTransformIdentity;
关于objective-c - 为 UIView 设置动画并将圆角半径保持为圆形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31428687/