views:

303

answers:

1

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

+2  A: 

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.

Can Berk Güder