Skip to content

Instantly share code, notes, and snippets.

@mjunaidi
Created December 28, 2017 07:30
Show Gist options
  • Save mjunaidi/701c26942f1a5aad4eed3dbb4e090e10 to your computer and use it in GitHub Desktop.
Save mjunaidi/701c26942f1a5aad4eed3dbb4e090e10 to your computer and use it in GitHub Desktop.
UIStackView + UIView test
import UIKit
var a = UIView()
var b = UIView()
var c = UIView()
a.backgroundColor = #colorLiteral(red: 0.1019607857, green: 0.2784313858, blue: 0.400000006, alpha: 1)
b.backgroundColor = #colorLiteral(red: 0.9254902005, green: 0.2352941185, blue: 0.1019607857, alpha: 1)
c.backgroundColor = #colorLiteral(red: 0.4666666687, green: 0.7647058964, blue: 0.2666666806, alpha: 1)
var stackView = UIStackView(frame: CGRect(x: 0, y: 0, width: 500, height: 800))
stackView.axis = .vertical
stackView.distribution = .fill
a.heightAnchor.constraint(equalToConstant: 70).isActive = true
b.heightAnchor.constraint(greaterThanOrEqualToConstant: 0).isActive = true
c.heightAnchor.constraint(equalToConstant: 70).isActive = true
stackView.addArrangedSubview(a)
stackView.addArrangedSubview(b)
stackView.addArrangedSubview(c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment