【发布时间】:2015-09-11 05:27:15
【问题描述】:
当我点击“登录”按钮时,我需要制作我的矩形登录按钮 Login Screenshot 动画并将其形状更改为圆形,如下面的链接 Login Button after i click
我在 stackoverflow 中看到了这段代码,但它没有按我想要的方式工作
CGFloat width = self.login.frame.size.width;
CABasicAnimation *morph = [CABasicAnimation animationWithKeyPath:@"cornerRadius"];
morph.fromValue = @0;
morph.toValue = @(width/2);
morph.duration = 0.5;
[self.login.layer addAnimation:morph forKey:@"morph"];
self.login.layer.cornerRadius = width/2;
请帮忙
感谢您回答这个问题。
这是最终代码
[UIView animateWithDuration:0.5
delay:0.0
options:UIViewAnimationCurveLinear
animations:^{
self.layoutWidth.constant = 70;
[self.view layoutIfNeeded];
self.btnLogin.clipsToBounds = YES;
self.btnLogin.layer.cornerRadius =self.btnLogin.bounds.size.height/2.0f;
}
completion:^(BOOL finished){
}];
【问题讨论】:
标签: ios objective-c animation uibutton