tig*_*ero 1 core-animation uibutton ios5
我有一个可移动的按钮,并希望在用户点击该按钮时执行一个方法 - 这可能在ios中吗?
我编写了以下代码,但需要完成动画才能触发该函数:
[arrowButton addTarget:self action:@selector(presentMainWindow) forControlEvents:UIControlEventTouchUpInside];
[UIView animateWithDuration:kAnimationDuration
delay:.2f
options:UIViewAnimationOptionCurveEaseInOut
animations:
^{
[arrowButton setTransform:CGAffineTransformMakeTranslation(kButtonShift, 0)];
[arrowButton setFrame:CGRectMake(arrowButton.frame.origin.x + kButtonShift, arrowButton.frame.origin.y, arrowButton.frame.size.width, arrowButton.frame.size.height);
}
completion:nil];
Run Code Online (Sandbox Code Playgroud)
我发现你可以简单地将选项UIViewAnimationOptionAllowUserInteraction添加到动画中来处理动画和交互:
[UIView animateWithDuration:kAnimationDuration
delay:.2f
options:UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionAutoreverse | UIViewAnimationOptionAllowUserInteraction
animations:
^{
[arrowButton setTransform:CGAffineTransformMakeTranslation(kButtonShift, 0)];
}
completion:nil];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1349 次 |
| 最近记录: |