Iphone 自定义滚动视图指示器
我目前正在为客户开发一个应用程序,他们提出了一个奇怪的请求。该请求涉及将自定义图像作为滚动视图的指示器。我什至不确定这是否可能,但如果可以,请让我知道如何做到这一点。
谢谢
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
UIScrollView
拉伸一个小的半透明圆形图像以生成其滚动条。您可以找到此图像作为UIScrollView
的第一个子视图:但是,正如我所说,此图像被拉伸,并且据我所知,在绘制滚动条时仅考虑 alpha 值。
因此,例如,如果您只对更改滚动条的顶部/底部感兴趣,则可以尝试更改此图像。然而,我怀疑你能否做任何有趣的事情。
我想到的一个可能的解决方案(这只是一个理论)是在
UIScrollView
之上添加一个自定义的、透明的UIView
。然后您可以隐藏默认滚动条(通过使用showsHorizontalScrollIndicator和showsVerticalScrollIndicator),将必要的触摸事件传递给UIScrollView来滚动内容,并在您的自定义视图中绘制滚动条。UIScrollView
streches a small, semi-transparent circle image to generate its scrollbars. You can find this image as the first subview of aUIScrollView
: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 aUIScrollView
. Then you can hide the default scroll bar (by usingshowsHorizontalScrollIndicator
andshowsVerticalScrollIndicator
), pass the necessary touch events to theUIScrollView
to scroll the content, and draw the scrollbars in your custom view.