我正在使用 UIScrollView 并使用scrollRectToVisible:animated
这对我来说效果很好。
但我想慢慢滚动到一个位置,以便用户可以注意到效果。
是否可以。
我正在尝试以下代码,但没有成功。
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:2.0];
[scrlView scrollRectToVisible:<<some cgrect>> animated:YES];
[UIView commitAnimations];
解决方案实际上非常简单。如果你使用[scrollView scrollRectToVisible:frame animated:YES]
滚动视图将启动它自己的动画,因此为了根据您的持续时间制作动画,您必须使用[scrollView scrollRectToVisible:frame animated:NO]
在你的动画中。
换句话说:这会起作用。
[UIView animateWithDuration:3
delay:0
options:UIViewAnimationOptionCurveEaseInOut
animations:^{ [scrollView scrollRectToVisible:frame animated:NO]; }
completion:NULL];
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)