This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Dog { | |
var name: String | |
} | |
struct Person { | |
var name: String | |
var age: Int | |
var dog: Dog | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DetailedPersonViewModel: PersonViewModel { | |
var title: String | |
var birthday: String | |
var dateFormatter = DateFormatter() | |
init(person: Person) { | |
title = person.firstName + " " + person.lastName | |
dateFormatter.dateStyle = .short | |
birthday = dateFormatter.string(from: person.birthday) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol PersonViewModel { | |
var title: String {get} | |
var birthday: String {get} | |
func doSomeWork() | |
} | |
class PersonView: UIView { | |
private var titleLabel: UILabel! | |
private var birthdayLabel: UILabel! | |
private var workButton: UIButton! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PersonView: UIView { | |
private var titleLabel: UILabel! | |
private var birthdayLabel: UILabel! | |
private var workButton: UIButton! | |
private var person: Person | |
private var dateFormatter = DateFormatter() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Person { | |
var firstName: String | |
var lastName: String | |
var birthday: Date | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var buttonLeftConstraint: NSLayoutConstraint? | |
func pureLayout() { | |
buttonLeftConstraint = animateButton.autoPinEdge(toSuperviewEdge: .left, withInset: 20) | |
animateButton.autoPinEdge(toSuperviewEdge: .top, withInset: 50) | |
animateButton.autoSetDimensions(to: CGSize(width: 100, height: 100)) | |
} | |
func animate() { | |
UIView.animate(withDuration: 1) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func pureLayout() { | |
scrollView.autoPinEdgesToSuperviewEdges(with: .zero) | |
scrollView.autoPinEdge(.bottom, to: .bottom, of: longer, withOffset: 20) | |
box.autoPinEdge(toSuperviewEdge: .top, withInset: 150) | |
box.autoAlignAxis(toSuperviewAxis: .vertical) | |
box.autoSetDimensions(to: CGSize(width: 100, height: 100)) | |
circle.autoPinEdge(.bottom, to: .bottom, of: self.view, withOffset: -20, relation: .lessThanOrEqual) | |
circle.autoPinEdge(.bottom, to: .top, of: longer, withOffset: -20, relation: .lessThanOrEqual) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func pureLayout() { | |
scrollView.autoPinEdgesToSuperviewEdges(with: .zero) | |
scrollView.autoPinEdge(.bottom, to: .bottom, of: longer, withOffset: 20) | |
box.autoPinEdge(toSuperviewEdge: .top, withInset: 50) | |
box.autoPinEdge(.left, to: .left, of: self.view, withOffset: 20) | |
box.autoSetDimensions(to: CGSize(width: 100, height: 100)) | |
circle.autoPinEdge(.top, to: .top, of: box) | |
circle.autoPinEdge(.right, to: .right, of: self.view, withOffset: -20) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func pureLayout() { | |
box.autoPinEdge(toSuperviewEdge: .top, withInset: 50) | |
box.autoPinEdge(toSuperviewEdge: .left, withInset: 20) | |
box.autoSetDimensions(to: CGSize(width: 100, height: 100)) | |
circle.autoPinEdge(.top, to: .top, of: box) | |
circle.autoPinEdge(toSuperviewEdge: .right, withInset: 20) | |
circle.autoSetDimensions(to: CGSize(width: 100, height: 100)) | |
longer.autoPinEdge(toSuperviewEdge: .left, withInset: 20) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var buttonLeftConstraint: NSLayoutConstraint? | |
func pureLayout() { | |
buttonLeftConstraint = animateButton.autoPinEdge(toSuperviewEdge: .left, withInset: 20) | |
animateButton.autoPinEdge(toSuperviewEdge: .top, withInset: 50) | |
animateButton.autoSetDimensions(to: CGSize(width: 100, height: 100)) | |
} | |
func animate() { | |
UIView.animate(withDuration: 1) { |
NewerOlder