开发者

Create a timeline with UIScrollView

开发者 https://www.devze.com 2023-03-31 15:49 出处:网络
I am trying to implement a timeline with UIScrollView. Basically, all zoomed out, it should show the one \"combined value\" for a year.

I am trying to implement a timeline with UIScrollView.

Basically, all zoomed out, it should show the one "combined value" for a year. If you zoom in and the zoomScale passes a specific threshold, I want to show the "combined values" for the individual months, and if you zoom further, it should show the real values for the individual days.

So I thought about creating multiple Custom Views for Years, containing Custom Views for Months, containing Custom Views for Days. The content size of my scroll view would be huge (e.g. if one day in full zoom is something like 30 - 50px) and the memory usage massive.

then I made my scroll view only scaling the x axis.

but I am not sure if this is the best way to implement it, I have a lot of trouble with proper sizing of my UI elements (labels for months, showing borders,开发者_Go百科 etc.), so what would be your approach?

I also thought about doing some shifting with 3 screen-sized views.

and again I have no clue how to implement zoom on this method.

would appreciate some fresh thoughts and ideas on how to do this.

Cheers, Felix


Have a look at the UIScrollViewDelegate method:

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView

You can implement this method to return different views for different zoom levels. I built an app a while back using three separate views to show a calendar-like timeline, but now wished I had implemented it using the delegate method above. Good luck.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号