Reputation: 22731
I want to build a login screen as on this screenshot:
I am not sure what the best approach for this would be and I am looking for a simple solution.
I thought about different approaches, but I believe that there has to be an easier one. This is what I had in mind so far:
Building the whole UI as a UITableView
with static cells. I can then define 3 sections in the storyboards, the first one only has one cell and shows the UILabel
on top, the second one contains the buttons and the email and password fields (possibly with three different cells) and finally the third section for the UIButton
on the bottom.
Using only a UIViewController
, place the UI elements and use AutoLayout for the arrangement (I would use AutoLayout in the first option as well). Only I am not sure how I can create these two UITextFields
sticking together and having rounded corners on top and bottom.
I tried using a grouped table view, as this look usually was the default one, but somehow this style doesn't seem to be there any more (was it dismissed with iOS 8?)?
One problem there is with the second solution is that I have another, quite similar view that should be used for sign up. There I basically want to use the exact same layout, only with more cells. So, in this case the scrolling that comes for free with UITableView
is actually needed, whereas for the login that's probably not very important.
Upvotes: 0
Views: 120
Reputation: 131398
I would advise against trying to shoehorn your UI into a table view.
I would suggest the following:
Make a regular view controller that contains all the UI elements in your UI, and a container view where the table view goes. Then link the container view with a table view controller via an embed segue.
The container view and embed segue will cause the table view to be set up as a child view controller. It is very easy to do and works very well.
I have a demo project on github (link) that shows how to do this. My project hosts 2 table views inside a normal view controller.
Upvotes: 2