iOS   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – 基于ScrollView位置的UIImageView淡化大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个翻转不同页面的UIPageControl.用户从第1页滚动到第2页时,我想让UI ImageView开始消失.我正在努力找出根据位置添加图层的正确方法.非常感激任何的帮助…

[UIView beginAnimations:@"fade out" context:nil];
    [UIView setAnimationDuration:1.0]; // some how based on position?? 
    imageView.alpha = 1.0; // here to?
    [UIView commitAnimations];

编辑:

设置委托:

self.pageController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];

    self.pageController.datasource = self;

解决方法

您需要委托来覆盖以下方法

- (void)scrollViewDidScroll:(UIScrollView *)scrollView;

然后,您应该检查scrollView.contentOffset.x值以确定滚动视图水平滚动的程度,并使用它来确定imageView的alpha,如下所示:

CGFloat newAlpha = scrollView.contentOffset.x / scrollView.frame.size.width; // This will need to be adapted depending on the content size of your scroll view -- do not just copy and paste this expecTing it to work :)
imageView.alpha = newAlpha;

大佬总结

以上是大佬教程为你收集整理的ios – 基于ScrollView位置的UIImageView淡化全部内容,希望文章能够帮你解决ios – 基于ScrollView位置的UIImageView淡化所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。