当我点击“登录”按钮时,我需要制作我的矩形登录按钮 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){
}];
答案 0 :(得分:0)
试试这个,
代码:
.main-div{ width: 300px;}
.float-left{ float: left; }
.float-left:first-child {background: yellow;}
.float-left:last-child {background: green;}
.float-right{ float: right; }
.float-right:first-child{background: blue;}
.float-right:last-child{background: red;}
输出: