Skip to content

Instantly share code, notes, and snippets.

@ignazioc
Created July 14, 2017 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ignazioc/c9e5ca8bfd7a68409218c5e644535280 to your computer and use it in GitHub Desktop.
Save ignazioc/c9e5ca8bfd7a68409218c5e644535280 to your computer and use it in GitHub Desktop.
//: Playground - noun: a place where people can play
import UIKit
import PlaygroundSupport
struct User {
var name: String
init() {
name = ""
}
}
class UserProfile: UILabel {
var user: User = User() {
didSet {
self.text = user.name
}
}
}
let container = UIView(frame: CGRect(x: 0, y: 0, width: 400, height: 100))
let userProfileView = UserProfile(frame: CGRect(x: 0, y: 0, width: 400, height: 50))
userProfileView.backgroundColor = UIColor.purple
userProfileView.textColor = UIColor.white
userProfileView.textAlignment = .center
container.addSubview(userProfileView)
var user = User()
userProfileView.user = User()
userProfileView.user.name = "Sirst Update"
userProfileView
userProfileView.user.name = "Second Update"
userProfileView
PlaygroundPage.current.liveView = container
PlaygroundPage.current.needsIndefiniteExecution = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment