views:

57

answers:

2

I'm trying to make a timeline view that shows events as UIButtons that can be pressed for more info.

Ideally I want to lay out the buttons on a UIScrollView, and allow them to stretch/shrink horizontally, but not vertically.

What I'm trying to accomplish would basically be equivalent to using pinch gestures to resize the content view, and using a scroll view to move side to side - could you point me in the right direction, or suggest how you might accomplish something like this?

My first thought is a UIScrollView to scale a UIView subview, and have the UIView subview contain another subview that does not resize vertically, but only does horizontally when bounds change, and disable vertical scrolling. Maybe I could skip one of these UIView subviews and have only one do everything. It just feels like I'm trying to hack this together like an HTML page or something with all these containers.

Not sure if I've explained any of this well enough to hope for an answer, any help is appreciated though.

A: 

Haven't tried this, but you could try placing everything in a UIScrollView, and whenever you detect a zoom level change, adjust all of the child view transforms to CGAffineTransformMakeScale(1.0, 1.0/zoomLevel). This way, the scrollview is zooming everything up, but each subview is scaling themselves vertically downward, canceling out the zoom.

Jason
I suspect you are on the right track, my efforts haven't worked yet though, where do you set this affine transform in the subviews?
Alex Gosselin
In the `scrollViewDidZoom` delegate callback. Haven't tried it though.
Jason
Sorry what I meant was what selector do I call on the subviews, i.e.:[subview setSomething:CGAffineTransformMakeScale(1.0, 1.0/zoomLevel)];
Alex Gosselin
`subview.transform = CGAffineTransformMakeScale(1.0, 1.0/zoomLevel);`
Jason
A: 

Assuming you don't actually want to stretch/shrink the button text, the easiest way is to resize all the buttons. I know, it's a pain.

tc.