如何在 xamarin ios 的滚动视图中添加滚动条? [英] How add a scroll bar in the scroll view of xamarin ios ?
问题描述
我在 xaml 页面中有一个滚动视图.但是我找不到与之关联的滚动条.没有可用于显示滚动条的属性.我应该添加一个自定义渲染器类来显示滚动条吗?
I have a scroll view in xaml page. But I could not find a scroll bar associated with it. No property is available to show the scroll bar. Should I add a custom renderer class to display scroll bar?
推荐答案
UIScrollView
没有Win32-style"总是在滚动条上,有一个滚动指示器可以在你滚动时显示向用户显示他们在可滚动视图中的位置.
UIScrollView
do not have "Win32-style" always on scrollbars, there is a scroll indicator that can to shown while you are scrolling to show the user where they are within the scrollable view.
在自定义渲染器 (ScrollViewRenderer
) 中,您可以设置以下项目:
In a custom renderer (ScrollViewRenderer
) you could set items like:
scrollView.ShowsHorizontalScrollIndicator = true;
scrollView.ShowsVerticalScrollIndicator = true;
scrollView.IndicatorStyle = UIScrollViewIndicatorStyle.Black;
scrollView.ScrollIndicatorInsets = new UIEdgeInsets(0, 30, 0, 30);
但是,同样,内置滚动指示器只会在用户实际滚动时显示在屏幕上.
But, again, the built-in scroll indictor will only be shown on screen while the user is actually scrolling.
如果您一直需要它们在屏幕上,您需要自己绘制滚动条.
If you need them on screen all the time you would need to draw the scrollbars yourself.
注意:这与 OS-X 滚动视图的行为相同.
Note: This is the same behavoir as the OS-X scroll view.
这篇关于如何在 xamarin ios 的滚动视图中添加滚动条?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!