Skip to content

Instantly share code, notes, and snippets.

@onevcat
Created October 21, 2015 08:33
Show Gist options
  • Save onevcat/cae76eb3f2606406e355 to your computer and use it in GitHub Desktop.
Save onevcat/cae76eb3f2606406e355 to your computer and use it in GitHub Desktop.
Extension
extension UILabel {
@IBInspectable var localizedKey: String? {
set {
if let s = newValue {
text = NSLocalizedString(s, comment:"")
}
}
get {
return text
}
}
}
extension UIButton {
@IBInspectable var localizedKey: String? {
set {
if let s = newValue {
setTitle(NSLocalizedString(s, comment:""), forState: .Normal)
}
}
get {
return titleLabel?.text
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment