UIScrollview,它可以向下拖动,直到你可以看到它后面的父视图
我已经设置了
scrollview.bounces = NO;
,但找不到任何其他可能相关的内容。当滚动视图位于视图的顶部或底部并且我尝试进一步滚动它时,它会向下滑动,我可以看到它后面的父视图。
有什么办法可以阻止这种行为吗?
谢谢, -代码
I've set
scrollview.bounces = NO;
and I cannot find anything else that maybe relevant. When the scrollview is at the top or botton of the view and i try and scroll it further, it slides down and I can see the parent view behind it.
Is there something that can be done to stop this behavious?
Thanks,
-Code
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在本例中,UIScrollView 有 2 个相关部分。滚动视图内容和滚动视图。
您的滚动视图不会在滚动/拖动时移动。
CGRect
框架保持不变。您的滚动视图内容在滚动/拖动时上下移动。
听起来滚动视图的内容有一个不透明的背景,隐藏了滚动视图后面的内容。但是,当您超出内容的范围时,您会看到滚动视图后面的内容,因为滚动视图本身具有透明背景。
解决方案:为您的
UIScrollView
提供不透明的背景。There are 2 relevant parts to the
UIScrollView
in this case. The scroll view contents and the scroll view.Your scrollview doesn't move on a scroll/drag. The
CGRect
frame stays constant.Your scrollview contents move up and down on scroll/drag.
It sounds like the contents of your scroll view have an opaque background which hides the stuff behind the scrollview. But when you go beyond the bounds of the contents, you are see what is behind the scroll view because the scrollview itself has a transparent background.
Solution: Give your
UIScrollView
a opaque background.让你的父视图 Alpha 为零。这将解决您的问题,并且您无需对 UIScrollView 进行任何更改。
Make your parent view alpha to zero. That will solve your problem and you don't have to do any changes on UIScrollView.
尝试
try