IOS:在带有动画的 ImageView 下禁用滚动视图

发布于 2024-12-11 10:49:50 字数 465 浏览 0 评论 0原文

在我的应用程序中,我有一个“启用分页”的滚动视图,当我选择一个页面时,图像视图以这种方式开始其动画

- (void) beginWinAnimation{
[UIView animateWithDuration:2.5
                 animations:^{successView.alpha = 1.0;}
                 completion:^(BOOL finished){ 

                 [UIView animateWithDuration:2.5
                 animations:^{successView.alpha = 0;}];
                 }];}

。在此动画期间,我可以看到此 successView 下的滚动视图,并且可以移动滚动视图页面;我希望在动画过程中你不能移动滚动视图,但只能在动画完成时移动,这可能吗?

In my app, I have a scrollview with "paging enabled" and when I chose a page an imageview start its animation in this way

- (void) beginWinAnimation{
[UIView animateWithDuration:2.5
                 animations:^{successView.alpha = 1.0;}
                 completion:^(BOOL finished){ 

                 [UIView animateWithDuration:2.5
                 animations:^{successView.alpha = 0;}];
                 }];}

During this animation I can see the scrollview under this successView and I can move scrollview page; I want that during animation you can't move the scrollview but only when animation is finished, is it possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无所的.畏惧 2024-12-18 10:49:50

是的,这是可能的。当动画开始时设置[scrollView setScrollEnabled:NO];动画完成后将其设置回YES

所以在你的代码中,它看起来像 -

- (void) beginWinAnimation{

[scrollView setScrollEnabled:NO];

[UIView animateWithDuration:2.5
                 animations:^{
                     successView.alpha = 1.0;
                 }
                 completion:^(BOOL finished){ 
                     [UIView animateWithDuration:2.5
                         animations:^{successView.alpha = 0;}
                         completion:^(BOOL finished){ 
                             [scrollView setScrollEnabled:YES];
                         }]; 
                 }];}

看看这是否有效。

Yes it's possible. When the animation starts set [scrollView setScrollEnabled:NO]; After your animation is complete set it back to YES.

So in your code, it will look like -

- (void) beginWinAnimation{

[scrollView setScrollEnabled:NO];

[UIView animateWithDuration:2.5
                 animations:^{
                     successView.alpha = 1.0;
                 }
                 completion:^(BOOL finished){ 
                     [UIView animateWithDuration:2.5
                         animations:^{successView.alpha = 0;}
                         completion:^(BOOL finished){ 
                             [scrollView setScrollEnabled:YES];
                         }]; 
                 }];}

See if this works.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文