我有一个圈子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];
Run Code Online (Sandbox Code Playgroud)
后来我想把它的大小改成更大的一个,但是当我这样做时,在动画开始时你会看到一些矩形形状,而不是它变回圆形.
我想要一个平面动画,当它的框架正在改变时,它会像圆圈一样停留.
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){ }];
Run Code Online (Sandbox Code Playgroud)
如果您只想缩放视图大小,则可以使用下面的代码.
[UIView animateWithDuration:2.0 animations:^{
con.transform = CGAffineTransformMakeScale(2, 2); // it will scale as double size
}completion:^(BOOL finished) {
// do whatever at animation completion
}
}];
Run Code Online (Sandbox Code Playgroud)
要将视图重置回正常大小,
con.transform = CGAffineTransformIdentity;
参考:https://developer.apple.com/library/ios/documentation/GraphicsImaging/Reference/CGAffineTransform/index.html#//apple_ref/c/func/CGAffineTransformMakeScale
| 归档时间: |
|
| 查看次数: |
2070 次 |
| 最近记录: |