Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Iphone Custom Scrollview indicator

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

like image 967
Hrithik Avatar asked Apr 15 '10 21:04

Hrithik


1 Answers

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.

like image 111
Can Berk Güder Avatar answered Sep 25 '22 20:09

Can Berk Güder