5.5. Second screen, part 1: Setting up the View of the Add Expense Screen
When the user clicks the plus Bar button (+), we should populate a screen to add a new expense. So, let's create two new files: AddExpenseView.swift (subclass of UIView) and AddExpenseViewController.swift (subclass of UIViewController). And add them to a new group, "Add Expense Screen." (Use the Cocoa Touch Class template, not a Swift file template).
Setting up the View
We can see that we need the following UI elements:
Two TextFields to put the title and amount of the expense.
One Label to display "Select the type of expense:"
One PickerView to select the types of expenses.
One button to finally Add an expense.
Let's open AddExpenseView.swift file and put the following codes to build the front end:
This file should be very straightforward to understand. Now that we have added our front end, we will now get to the controller code (AddExpenseViewController).