Repo created
This commit is contained in:
parent
4af19165ec
commit
68073add76
12458 changed files with 12350765 additions and 2 deletions
47
iphone/Maps/Core/Theme/Renderers/UITextFieldRenderer.swift
Normal file
47
iphone/Maps/Core/Theme/Renderers/UITextFieldRenderer.swift
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
extension UITextField {
|
||||
@objc override func applyTheme() {
|
||||
for style in StyleManager.shared.getStyle(styleName)
|
||||
where !style.isEmpty && !style.hasExclusion(view: self) {
|
||||
UITextFieldRenderer.render(self, style: style)
|
||||
}
|
||||
}
|
||||
|
||||
@objc override func sw_didMoveToWindow() {
|
||||
guard MapsAppDelegate.theApp().window === window else {
|
||||
sw_didMoveToWindow();
|
||||
return
|
||||
}
|
||||
applyTheme()
|
||||
isStyleApplied = true
|
||||
sw_didMoveToWindow();
|
||||
}
|
||||
}
|
||||
|
||||
class UITextFieldRenderer {
|
||||
class func render(_ control: UITextField, style: Style) {
|
||||
if let cornerRadius = style.cornerRadius {
|
||||
control.layer.setCornerRadius(cornerRadius)
|
||||
control.clipsToBounds = true
|
||||
}
|
||||
control.borderStyle = .none
|
||||
var placeholderAttributes = [NSAttributedString.Key : Any]()
|
||||
if let backgroundColor = style.backgroundColor {
|
||||
control.backgroundColor = backgroundColor
|
||||
}
|
||||
if let font = style.font {
|
||||
control.font = font
|
||||
placeholderAttributes[NSAttributedString.Key.font] = font
|
||||
}
|
||||
if let fontColor = style.fontColor {
|
||||
control.textColor = fontColor
|
||||
}
|
||||
if let tintColor = style.tintColor {
|
||||
control.tintColor = tintColor
|
||||
placeholderAttributes[NSAttributedString.Key.foregroundColor] = tintColor
|
||||
}
|
||||
if let attributedPlaceholder = control.attributedPlaceholder, !attributedPlaceholder.string.isEmpty {
|
||||
control.attributedPlaceholder = NSAttributedString(string: attributedPlaceholder.string,
|
||||
attributes: placeholderAttributes)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue