Created
July 14, 2017 11:43
-
-
Save ignazioc/c9e5ca8bfd7a68409218c5e644535280 to your computer and use it in GitHub Desktop.
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
//: 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