Skip to content

Instantly share code, notes, and snippets.

@classx
Forked from iamazhar/BirdLiveView.swift
Created April 22, 2019 06:23
Show Gist options
  • Select an option

  • Save classx/1d20e37a03ea9c1921212c79c5a4e93d to your computer and use it in GitHub Desktop.

Select an option

Save classx/1d20e37a03ea9c1921212c79c5a4e93d to your computer and use it in GitHub Desktop.
//1
let image = UIImage(named: "swifty")!
let swifty = Bird(name: "Swifty", rarity: .veryRare, image: image)
//2
let viewModel = BirdViewModel(bird: swifty)
//3
let frame = CGRect(x: 0, y: 0, width: 300, height: 450)
let view = BirdView(frame: frame)
//4
view.nameLabel.text = viewModel.name
view.imageView.image = viewModel.image
view.purchaseFeeLabel.text = viewModel.purchaseFeeText
//5
// Present the view controller in the Live View window
PlaygroundPage.current.liveView = view
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment