Reputation: 2170
I'm developing an iOS app in which I want a scroll bar like element that is not attached to any UIScrollView . Right now I'm customising a UISlider to look like a scroll bar . I would like to know if there is any other way .
Heres what I'm trying to do :
I m making PDF viewer , So I have this scroller below the PDF View . When you scroll it a small pop over containing the preview of the target page appears . When you stop scrolling it changes to that page .
Upvotes: 0
Views: 1384
Reputation: 7839
Really, you could use any image for this, however you would like it styled, then add it as a separate entity to the scroll view.
All you'd need to do then is calculate it's position based on the current scroll amount (calculated from the difference between contentOffset
and contentSize
).
In the past, I've been able to get some quite unique sets of scroll views using this method.
EDIT:
You could create two UIImageViews one for the 'runner' and one for the 'scroll icon' such as below:
Then you could arrange them on top of each other.
You'd need to then get some sort of algorithm on this view to calculate the position of the icon on the runner. This can be done by calculating the difference between the contentOffset
and contentSize
properties of your UIScrollView.
If the contentSize is 3000, and the current contentOffset is 1500, the icon would then be in the centre of the runner.
You could add this to your scrollViewDidScroll
delegate method.
Then you'd need to reverse program this so it also responds to touch, and depending on the position of the icon on the runner, you could work out where to navigate to on your UIScrollView.
Upvotes: 2
Reputation: 10633
You might want to look at the similar effect available with TimeScroller
Upvotes: 0