Thumbnail slider in toolbar like iPad Photos app

2020-06-28 10:40发布

I would like to put thumbnails in the toolbar like the Photos app. Like the screenshot on the left:

alt text
(source: apple.com)

Is there is a built-in control to do this, or do I have to implement it from scratch?

If the answer is from scratch, any tips?

3条回答
相关推荐>>
2楼-- · 2020-06-28 10:42

Should anyone still need it, I made an effort of coming up with ThumbnailPickerView - a simple UI control resembling Photos.app thumbnail slider.

查看更多
祖国的老花朵
3楼-- · 2020-06-28 10:54

From scratch, is the answer, unfortunately.

You create a custom view and add your array of images as subviews using UIImageView objects incrementing your x position by the the thumbnail width you've determined to use.

Then override the touch events for you custom view. Determine which image view the touch is currently over in -touchesMoved and use Core Animation to animate the current view's scale making it larger than the rest. Add the custom view to your toolbar wrapping your custom view in a UIBarButtonItem using -initWithCustomView.

Remember to enable user interaction on your custom view or you won't receive any touch events. If you need help with the code, update your question with some code specific questions.

查看更多
家丑人穷心不美
4楼-- · 2020-06-28 11:04

This would be a control you'd have to write yourself. I'm not what the best approach would be, but I think I'd go with subclassing a UISlider, drawing the array of images next to each other to create the track, and then using the current image as the handle.

查看更多
登录 后发表回答