iDec
iDec

Reputation: 727

Horizontal scrollview activated with button

I'm trying to get the effect showed in the image below:

enter image description here

The blue box is supposed to be the UIScrollView. Once you launch the application what you see is button 1 and 2, but I want that when the user pushes button 1 for example, the scroll view moves horizontally to the left and shows Text Field 1 and 2 in the same position where the buttons were.

I guess the UIScrollView is the best way to do it and then implement in one of the buttons the code to make that transition (using Core Graphics?). If you have any better idea or a link with a tutorial with same effect would be great.

Thank you in advance!

Upvotes: 0

Views: 121

Answers (1)

Michael
Michael

Reputation: 1107

A simple way to do it (mostly) with Storyboard:

Make a UIView which will act as container for your buttons and textfields with 640 width

containerview

Make sure the view is at positioned at x: 0 then add the buttons, now make x: -320 and add the textFields

textfields

Next link the container view to your code by ctrl+dragging it and name it (mine bottomMenuView)

bottomMenuViewIBOutlet

Now cntr+drag from your button1 to your .M code for an IBAction (mine button1Method)

buttonmethod

And finally move the x coordinate to reposition the container view with this method body

methodbody

Upvotes: 1

Related Questions