Intro to iOS Development
  • Welcome
    • ☀️Introduction
    • 🐣Getting Started
    • 🐦Course Staff
  • Logistics
    • 📜Syllabus
    • 🗓️Schedule
    • 🖊️Grading
    • 🙋‍♂️Office Hours
    • Ed Discussion
  • Assignments
    • 🍼A1: Swift Basics
    • 🧑A2: Profile
    • 💬A3: ChatDev
    • 👨‍🍳A4: ChefOS
    • 👨‍🍳A4: ChefOS - SwiftUI
    • 📱Hack Challenge
      • 🏆FA23 Winners
  • Lectures
    • 1️⃣Logistics + Swift Basics
    • 2️⃣UIKit + AutoLayout
  • 3️⃣MVC + Navigation + Delegation
  • 4️⃣UITableView
  • 5️⃣UICollectionView
  • 6️⃣Networking I
  • 7️⃣Networking II
  • 8️⃣SwiftUI I
  • 9️⃣SwiftUI II
  • 🔟Persistence + SnapKit
  • 🔔(11) Notifications
  • 🌎(12) Deployment and MapKit
  • Chapters
    • 🖐️Introduction
    • ☁️Git + GitHub
      • 1️⃣Git Installation
      • 2️⃣Git Basics
      • ➕Git+
    • 🐣Swift Basics
      • 1️⃣Variables and Constants
      • 2️⃣Data Types
      • 3️⃣Operators
      • 4️⃣Data Structures
      • 5️⃣Conditionals
      • 6️⃣Loops
      • 7️⃣Functions
      • 8️⃣Closures
      • 9️⃣Optionals
    • 🧰UIKit + AutoLayout
      • 1️⃣Classes
      • 2️⃣UIKit
      • 3️⃣AutoLayout
    • 📺MVC + Navigation + Delegation
      • 1️⃣MVC
      • 2️⃣Navigation
      • 3️⃣Delegation
    • 🏓UITableView
      • 1️⃣What is a UITableView?
      • 2️⃣UITableView Setup
    • 📚UICollectionView
      • 1️⃣What is a UICollectionView?
      • 2️⃣UICollectionView Setup
    • 🌐Networking I
      • 1️⃣HTTP Requests
      • 2️⃣Callbacks
      • 3️⃣Codable
    • 🌍Networking II
      • 1️⃣Alamofire
      • 2️⃣GET Requests
      • 3️⃣POST Requests
      • 4️⃣URLSession
    • 💾Persistence + SnapKit
      • 1️⃣Persistence
      • 2️⃣SnapKit
    • 🕊️SwiftUI
      • 1️⃣Introduction to SwiftUI
      • 2️⃣Getting Started with SwiftUI
      • 3️⃣Views + Modifiers
      • 4️⃣Layouts
      • 5️⃣Navigation
      • 6️⃣Property Wrappers
    • 🎛️Widgets
      • 1️⃣Introduction to Widgets
      • 2️⃣Setting Up Widgets
      • 3️⃣Building Widgets
      • 4️⃣Configuring Widgets
    • 🧱Project Foundation
    • ✅Testing
      • 1️⃣Unit Testing
    • 👣Debugging
      • 1️⃣OSLog
      • 2️⃣Crashlytics
      • 3️⃣Analytics
    • ☁️CI/CD
      • 1️⃣Xcode Cloud
      • 2️⃣AppStore Shipping
  • Guides
    • 🔨Xcode Project Setup
    • 🎨Figma
    • 📬Postman
    • 🥥CocoaPods
    • 🧰UIKit Handbook
    • 📑Tab Views
      • UITabBarController
      • TabView
  • Work in progress
    • 🧵Concurrency
    • 2️⃣UI Testing
    • 🕐Reactive Programming
    • 🧠Memory Management
      • 🔁ARC
    • 📦Storage
    • 📣Notifications
  • Archived
    • SP24
      • Logistics
        • 📜Syllabus
        • 🗓️Schedule
        • 🖊️Grading
        • 🙋‍♂️Office Hours
      • Assignments
        • 🍼A1: Swift Basics
        • 🧑A2: Profile
        • 💬A3: ChatDev
        • 👨‍🍳A4: ChefOS
        • 📱Hack Challenge
          • 🏆FA23 Winners
      • Lecture
        • 0️⃣Course Intro + Logistics + Git Setup
        • 1️⃣Swift Basics
        • 2️⃣UIKit + AutoLayout
        • 3️⃣MVC + Navigation + Delegation
        • 4️⃣UITableView
        • 5️⃣UICollectionView
        • 6️⃣Networking I
        • 7️⃣Networking II
        • 8️⃣Persistence + SnapKit
        • 🔟SwiftUI
        • 🔢TabViews
    • FA23
      • Logistics
        • 🐣Getting Started
        • 🐦Course Staff
        • 📜Syllabus
        • 🗓️Schedule
        • 🖊️Grading
        • 🙋‍♂️Office Hours
      • Assignments
        • 🍼A1: Swift Basics
        • 🧑A2: Profile
        • 💬A3: ChatDev
        • 👨‍🍳A4: ChefOS
        • 📱Hack Challenge
          • 🏆FA23 Winners
      • Lectures
        • 0️⃣Course Intro + Logistics
        • 1️⃣Swift Basics
        • 2️⃣UIKit + AutoLayout
        • 3️⃣MVC + Navigation + Delegation
        • 4️⃣UITableView
        • 5️⃣UICollectionView
        • 6️⃣Networking I
        • 7️⃣Networking II
        • 8️⃣Persistence + SnapKit
        • 🎛️Widgets
          • 👼Introduction to Widgets
          • ⚒️Setting Up Widgets
          • 🧱Building Widgets
          • 👨‍💻Configuring Widgets
        • 🔟SwiftUI
    • SP23
      • Logistics
        • Lecture Schedule
        • Syllabus
        • Grading
        • SP23 Office Hours
      • Chapters
        • 1. Intro to Swift & Xcode
          • Lecture Handout
          • Lecture Demo
          • 🍼Project: Swift Basics
        • 2. UIKit and AutoLayout
          • Lecture Handout
          • Lecture Demo
          • 🛒Project: UIKit + AutoLayout
        • 3. Navigation, MVC, and Delegation
          • Lecture Handout
          • Lecture Demo
          • Project: Navigation + Delegation
        • 4. UITableView
          • Lecture Handout
          • Lecture Demo
          • Project: UITableView
        • 5. UICollectionView
          • Lecture Handout
          • Lecture Demo
          • Project: UICollectionView
        • 6. Networking I
          • Lecture Handout
          • Lecture Demo
          • Project: Persistence
        • 7. Networking II
          • Lecture Handout
          • Lecture Demo
            • Message Board
          • Project: Networking II
        • 8. Swift UI
        • 9. CocoaPods
          • 🍫Lecture Handout
          • 🧑‍🍳Lecture Demo
      • Cheat Sheets
        • Setting Up a New Xcode Project
        • Submitting Your Projects
        • Setting Up CocoaPods
    • 2022
      • SwiftUI
    • 2021
      • Adding Flare
      • Project: UIView Animations (Optional - Extra Credit)
      • UIView Animations
      • Xcode Tips and Tricks
    • 2019
      • Firebase
      • Persistence: UserDefaults
  • Swift Guide (ARCHIVED)
    • About this Textbook
    • Documentation
    • Constants and Variables
      • Variable Properties
      • Lazy and Static Variables
    • Functions
    • Ranges
    • Arrays
      • Basic Array Operations
      • Iteration and Enumeration
      • Advanced Array Operations
    • Tuples
    • Conditions and While Loops
    • For Loops
    • Enums and Switches
      • Enums with Associated Values
      • Indirect Enums
    • Classes and Structs
    • Optionals
    • Dictionaries
      • Dictionary Implementation
    • Closures
    • Constraints
    • Generics
    • Protocols
      • Protocols With Associated Types
    • Casting
    • Errors
    • Networking
      • Result
    • Inout
Powered by GitBook
On this page
  • UIView
  • Text-Based Views
  • UILabel
  • UITextField
  • UITextView

Was this helpful?

Export as PDF
  1. Guides

UIKit Handbook

Original Author: Richie Sun

PreviousCocoaPodsNextTab Views

Last updated 1 year ago

Was this helpful?

UIView

An object that manages the content for a rectangular area on the screen. The class defines the behaviors that are common to all views. All following UI elements are a subclass of UIView

let view = UIView()

All UIViews share the following attributes:

Attribute
Type
Description

.alpha

CGFloat

The alpha value of the view.

.backgroundColor

UIColor

The background color of the view.

.bounds

CGRect

The view’s bounded rectangle that describes the view's location and size relative to its own coordinate system (Independent of any other views).

.clipsToBounds

Bool

A boolean value that determines if the view’s subviews are constrained by the bounds of the view.

.frame

CGRect

The view’s frame rectangle that describes the view's location and size relative to its superview’s coordinate system.

.isHidden

Bool

A boolean value that determines if the view is hidden.

.layer.cornerRadius

CGFloat

The radius utilized to round the corners of any view. Setting the corner radius equal to half the width/ height will make the view an ellipse.

.layer.borderColor

CGColor

The color of the view’s border. Note that you are not able to directly specify UIColors like .black. You must use the CGColor equivalent as follows: UIColor.black.cgColor

.layer.borderWidth

CGFloat

The width of the view’s border (in pixels).

.layer.opacity

Float

Specifies the opacity of the view. Value is a floating point number 0..1 inclusive, where 1 indicates an opaque view, and 0 indicates a completely transparent view (basically Hidden).

Text-Based Views

The following views are utilized for displaying text in your views. Whether that be for titles, headers, descriptions, or input text boxes.

All of the views in this section shared the following attributes:

Attribute
Type
Description

.font

UIFont

The font of the text (More setup needed for UITextView).

.text

String?

The text that the label displays.

.textAlignment

NSTextAlignment

The technique for aligning the text (.left, .center, .right).

.textColor

UIColor

The color of the text.

UILabel

A view that displays one or more lines of informational text. Most commonly used to display titles, headers, or short lines of text that are NOT scrollable.

let label = UILabel()

Unique attributes:

Attribute
Type
Description

.numberOfLines

Int

The maximum number of lines for your text. Setting this to 0 will allow any number of lines depending on the constraints

UITextField

An object that displays an editable text area in your interface. Most commonly used to obtain shorter text input from users, as the textField area is NOT scrollable nor multiline

let textField = UITextField()

Unique attributes:

Attribute
Type
Description

.borderStyle

BorderStyle

Specifies the basic border style of the textField. .none, .bezel, .line, .roundedRect are the options offered, but it is always better to use .layer to create custom borders

.delegate

UITextFieldDelegate?

The delegate used to keep track of and manage user interaction with the textField

.keyboardType

UIKeyboardType

Specifies the type of keyboard that the textField pulls up when interacted with. .default, .numberPad, .URL are commonly used

.placeholder

String?

The text string that displays when there is no other text in textField. Often used to indicate what information the user should input

UITextView

A scrollable, multiline text region.

let textView = UITextView()

Unique attributes:

Attribute
Type
Description

.delegate

UITextViewDelegate?

The delegate used to keep track of and manage user interaction with the textView

.keyboardType

UIKeyboardType

Specifies the type of keyboard that the textView pulls up when interacted with. .default, .numberPad, .URL are commonly used

.isEditable

Bool

A Boolean value that indicates whether the textView can be edited

.isScrollEnabled

Bool

A Boolean value that indicates whether the textView is scrollable

.isSelectable

Bool

A Boolean value that indicates whether the textView is selectable. NOTE: This must be set to true if you want to change the font!

More Views Coming Soon!

🧰
UIView