Dev Genius

Coding, Tutorials, News, UX, UI and much more related to development

Follow publication

Member-only story

Swift UIKit Cheat Sheet: The Ultimate Guide to Creating Views with Code

Arc Sosangyo
Dev Genius
Published in
3 min readFeb 26, 2025

--

Photo by Paul Skorupskas on Unsplash

Creating and Adding a UIView

class ViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()

let myView = UIView()
myView.backgroundColor = .systemBlue
myView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(myView)

NSLayoutConstraint.activate([
myView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
myView.centerYAnchor.constraint(equalTo

--

--

Published in Dev Genius

Coding, Tutorials, News, UX, UI and much more related to development

Written by Arc Sosangyo

Arc is an iOS Dev and app publisher, a former IT manager who transitioned to iOS engineering, and a big fan of AI, coding, science, history, and philosophy.

No responses yet

Write a response