Min*_*oud 3 uibutton ibaction ios jquery-animate
我想知道如何在点击通过时关闭UIButton的动画
-(IBAction)
Run Code Online (Sandbox Code Playgroud)
提前致谢!
你的内心 IBAction
UIButton *button = (UIButton*)sender;
//animates button 25 pixels right and 25 pixels down. Customize
CGRect newFrame = CGRectMake(button.frame.origin.x + 25, button.frame.origin.y + 25, button.frame.size.width, button.frame.size.height);
[UIView animateWithDuration:0.3f
delay:0.0f
options: UIViewAnimationOptionCurveLinear
animations:^{
[button setFrame:newFrame];
}
completion:nil];
Run Code Online (Sandbox Code Playgroud)
编辑 - 在帧之间切换
clicked在某处初始化布尔值为NO
if (!clicked){
//animates button 25 pixels right and 25 pixels down. Customize
CGRect newFrame = CGRectMake(button.frame.origin.x + 25, button.frame.origin.y + 25, button.frame.size.width, button.frame.size.height);
[UIView animateWithDuration:0.3f
delay:0.0f
options: UIViewAnimationOptionCurveLinear
animations:^{
[button setFrame:newFrame];
}
completion:nil];
clicked = YES;
} else {
//animates button 25 pixels left and 25 pixels up. Customize
CGRect newFrame = CGRectMake(button.frame.origin.x - 25, button.frame.origin.y - 25, button.frame.size.width, button.frame.size.height);
[UIView animateWithDuration:0.3f
delay:0.0f
options: UIViewAnimationOptionCurveLinear
animations:^{
[button setFrame:newFrame];
}
completion:nil];
clicked = NO;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4531 次 |
| 最近记录: |