With Xcode open, let's get started:
- Create a new project in Xcode. Go to File | New | Project | iOS App.
- In Main.storyboard, add the following:
- Add UISegmentedControl with two options (Photo / Camera Roll and Live Camera).
- Next, add a UILabel view just underneath.
- Add a UIImageView view beneath that.
- Finally, add a UIButton component.
- Space these accordingly using AutoLayout constraints with UIImageView being the prominent object:
Figure 11.1 – Camera/photo app
- Once we have this in place, let's hook these up to our ViewController.swift file:
@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var labelView: UILabel!
@IBAction func onSelectPhoto(_ sender: Any)
Take note that in the preceding, we have two IBOutlet and one IBAction (we don't need an outlet for UIButton, we just care about its action).
- Next, populate IBAction with the following code:
@IBAction...