Sat*_*yam 19 iphone uiscrollview
我正在使用UIScrollView并使用scrollRectToVisible:animated这对我来说很好.但我想慢慢滚动到某个位置,以便用户可以注意到该效果.可能吗.
我正在尝试以下代码,但没有成功.
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:2.0];
[scrlView scrollRectToVisible:<<some cgrect>> animated:YES];
[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)
voi*_*ern 56
解决方案实际上非常简单.如果你使用[scrollView scrollRectToVisible:frame animated:YES]scrollview将启动它自己的动画,所以为了使你的持续时间动画,你必须[scrollView scrollRectToVisible:frame animated:NO]在你的动画中使用.
换句话说:这会奏效.
[UIView animateWithDuration:3
delay:0
options:UIViewAnimationOptionCurveEaseInOut
animations:^{ [scrollView scrollRectToVisible:frame animated:NO]; }
completion:NULL];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9664 次 |
| 最近记录: |