iOS: Asset Catalogs, UIButton, CALayer & More…

Introduction

Outline

  1. Interface Builder
  2. Auto Layout
  3. Outlets
  1. @2x and @3x Images
  2. Asset Catalogs
  3. UIButton
  4. CALayer
  5. UIColor
  6. Random Numbers
  7. Actions
  8. UIAlertController

Designing Your Layout

An example of adding multiple constraints.
  1. In the image above, the pop-up was displayed because we Ctrl + drag from the top UIButton to its white space above and releasing. Traditionally, we would add another constraint by repeating the same process. Or…
  2. We can hold down the shift key before selecting an item in the menu, which will allow you to select more than 1 constraint in the pop-up.

Asset Catalogs

History

An example of setting constraints for the middle and bottom UIButtons.
An example of setting complete constraints for the UIButton (at the bottom).
  1. It has a Y position because we placed a constraint relative to the 2nd UIButton.
  2. It has an X position because we’re centering it horizontally.
  3. It has a width and height because it’s reading it from the image we assigned.
An example of creating an IBOutlet.

UIButton and CALayer

An example of utilizing the setImage() method.
An example of where CALayer is demonstrated.
An example of setting the RGBA for a UIColor.

Random Numbers

An example where randomization is being generated.

Create an IBAction

An example of an IBAction pop-up.
An example of where tags are being utilized.

UIAlertController

An example of where an UIAlertController is being used.
  1. .alert
  2. .actionSheet
  1. .default
  2. .cancel
  3. .destructive
  1. A view controller to present
  2. Whether to animate the presentation
  3. (Optional) A closure that should be executed when the presentation animation has finished
An example of how to solve the “Cannot convert value of type ‘() -> ()’ to expected argument type ‘((UIAlertAction) -> Void)?’.” error message.

--

--

iOS Developer | Full Stack Developer | Software Engineer | LinkedIn: john-kim-developer | GitHub: cloudiosx | Portfolio: cloudiosx.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
John Kim

iOS Developer | Full Stack Developer | Software Engineer | LinkedIn: john-kim-developer | GitHub: cloudiosx | Portfolio: cloudiosx.com