Currently there is nothing ready for that, but you can add an attribute to the Interface Builder
:
Just add this to a file, call it for example XIB+Extension.swift
:
public protocol UIXIBStyle {
var uppercased: Bool { get set }
}
extension UILabel: UIXIBStyle {
@IBInspectable public var uppercased: Bool {
get { return false }
set(key) {
if key {
text = text?.uppercased()
}
}
}
}
extension UIButton: UIXIBStyle {
@IBInspectable public var uppercased: Bool {
get { return false }
set(key) {
if key {
setTitle(currentTitle?.uppercased(), for: .normal)
}
}
}
}
And you will be able to see a new attribute called Uppercased under the Attribute Inspector
for any UILabel
or UIButton
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.