Iphone 自定义滚动视图指示器

发布于 2024-08-28 16:57:58 字数 101 浏览 11 评论 0原文

我目前正在为客户开发一个应用程序,他们提出了一个奇怪的请求。该请求涉及将自定义图像作为滚动视图的指示器。我什至不确定这是否可能,但如果可以,请让我知道如何做到这一点。

谢谢

I am currently working on an application for a client, and they have made an odd request. The request involves putting a custom image as the indicator for the scrollview. I am not even sure if this is possible but if it is can you please let me know how one would go about doing that.

Thanks

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

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

发布评论

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

评论(1

孤君无依 2024-09-04 16:57:58

UIScrollView 拉伸一个小的半透明圆形图像以生成其滚动条。您可以找到此图像作为 UIScrollView 的第一个子视图:

UIImageView *circle = [scrollView.subviews objectAtIndex:0];

但是,正如我所说,此图像被拉伸,并且据我所知,在绘制滚动条时仅考虑 alpha 值。

因此,例如,如果您只对更改滚动条的顶部/底部感兴趣,则可以尝试更改此图像。然而,我怀疑你能否做任何有趣的事情。

我想到的一个可能的解决方案(这只是一个理论)是在 UIScrollView 之上添加一个自定义的、透明的 UIView。然后您可以隐藏默认滚动条(通过使用showsHorizo​​ntalScrollIndicator和showsVerticalScrollIndicator),将必要的触摸事件传递给UIScrollView来滚动内容,并在您的自定义视图中绘制滚动条。

UIScrollView streches a small, semi-transparent circle image to generate its scrollbars. You can find this image as the first subview of a UIScrollView:

UIImageView *circle = [scrollView.subviews objectAtIndex:0];

However, as I said this image is stretched, and as far as I can tell, only the alpha values are considered when drawing the scroll bars.

So for example if you're only interested in changing the top/bottom ends of the scroll bar, you can try to change this image. However, I doubt you'll be able to do anything interesting.

A possible solution that comes to mind, and this is only a theory, is to add a custom, transparent UIView on top of a UIScrollView. Then you can hide the default scroll bar (by using showsHorizontalScrollIndicator and showsVerticalScrollIndicator), pass the necessary touch events to the UIScrollView to scroll the content, and draw the scrollbars in your custom view.

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