Skip to content

Instantly share code, notes, and snippets.

View nekonora's full-sized avatar
🎸
Making stuff using other stuff.

Filippo Zaffoni nekonora

🎸
Making stuff using other stuff.
View GitHub Profile
@nekonora
nekonora / addView.swift
Last active March 2, 2019 13:26
UIView quick add programatically
addedView = UIView()
addSubview(addedView)
addedView.translatesAutoresizingMaskIntoConstraints = false
addConstraints([
NSLayoutConstraint(item: addedView, attribute: .centerX, relatedBy: .equal, toItem: self, attribute: .centerX, multiplier: 1.0, constant: 0),
NSLayoutConstraint(item: addedView, attribute: .centerY, relatedBy: .equal, toItem: self, attribute: .centerY, multiplier: 1.0, constant: 0),
NSLayoutConstraint(item: addedView, attribute: .width, relatedBy: .equal, toItem: self, attribute: .width, multiplier: 1.0, constant: 0),
NSLayoutConstraint(item: addedView, attribute: .height, relatedBy: .equal, toItem: self, attribute: .height, multiplier: 1.0, constant: 0)