Lambda School iOS Labs Project

Lambda School Labs

Main User Interface

Programmatically Using Fixed Constraints

let constraint = NSLayoutConstraint(item: view1,
attribute: .width,
relatedBy: .equal,
toItem: nil,
attribute: .notAnAttribute,
multiplier: 1.0,
constant: 150.0)

Adding Constraints To a View

let constraint = NSLayoutConstraint(item: view1,
attribute: .leading,
relatedBy: .equal,
toItem: view2,
attribute: .trailing,
multiplier: 1.0,
constant: 10.0)

NSLayoutConstraint.activate([constraint])
let constraint = view1.leadingAnchor.constraint(equalTo: view2.trailingAnchor, constant: 10)
let constraint = view1.widthAnchor.constraint(equalToConstant: 150)

Facts about programmatic layout:

  • Code is a single source of truth of a UI component.
  • View setup is explicit. It is clear which properties are configured and how.
  • Merge conflicts are easier to resolve since we are dealing with code rather than XML.
  • Extensible for complex scenarios: screen rotation, animations, dynamic fonts, etc.
  • The consistent coding style of constructing UI programmatically is maintained across a mixed UIKit and SwiftUI project. With the gradual adoption of SwiftUI, this becomes more and more relevant.
  • Less noise in the codebase: no segues, string identifiers, tricky initialization from storyboard and xib, numerous helper extensions attempting to hide some part of that noise.

Story Squad (Scribble-Stadium) RC-1 Release

  • Integration of IOT and Cloud
  • AI integration

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

XCode Distribution Error — Profile doesn’t include the selected signing certificate

Open-Closed Principle in Swift

UITableView & UITableViewCell Without Storyboard — Swift 5

How to Add an Activity Loader in a UISearchBar

iOS Passwordless Chat Application with Auth0

Closures in swift and lambdas in kotlin

Writing Synchronous Code in Swift

‘TDCRoundButton’ Custom Rounded Gradient UIButton CocoapodIn Xcode 12 (Swift 5)

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
Pravin Patel

Pravin Patel

More from Medium

Researching to create a persuasive experience of e-commerce website

Redesigning the Leap Card App

Case Study #5-Wellness App

HABIT TRACKING APP