Commit dbcd077e by Daniel Dahan

references to NSAttributedStringKey clean up

parent 45363976
...@@ -33,44 +33,44 @@ import UIKit ...@@ -33,44 +33,44 @@ import UIKit
extension NSMutableAttributedString { extension NSMutableAttributedString {
/** /**
Adds a Dictionary of NSAttributedStringKeys for a given range. Adds a Dictionary of NSAttributedStringKeys for a given range.
- Parameter _ stringKeys: A Dictionary of NSAttributedStringKey type keys and Any type values. - Parameter _ keys: A Dictionary of NSAttributedStringKey type keys and Any type values.
- Parameter range: A NSRange. - Parameter range: A NSRange.
*/ */
open func addAttributes(_ stringKeys: [NSAttributedStringKey: Any], range: NSRange) { open func addAttributes(_ keys: [NSAttributedStringKey: Any], range: NSRange) {
for (k, v) in stringKeys { for (k, v) in keys {
addAttribute(k, value: v, range: range) addAttribute(k, value: v, range: range)
} }
} }
/** /**
Updates a NSAttributedStringKey for a given range. Updates a NSAttributedStringKey for a given range.
- Parameter _ stringKey: A NSAttributedStringKey. - Parameter _ key: A NSAttributedStringKey.
- Parameter value: Any type. - Parameter value: Any type.
- Parameter range: A NSRange. - Parameter range: A NSRange.
*/ */
open func updateAttribute(_ stringKey: NSAttributedStringKey, value: Any, range: NSRange) { open func updateAttribute(_ key: NSAttributedStringKey, value: Any, range: NSRange) {
removeAttribute(stringKey, range: range) removeAttribute(key, range: range)
addAttribute(stringKey, value: value, range: range) addAttribute(key, value: value, range: range)
} }
/** /**
Updates a Dictionary of NSAttributedStringKeys for a given range. Updates a Dictionary of NSAttributedStringKeys for a given range.
- Parameter _ stringKeys: A Dictionary of NSAttributedStringKey type keys and Any type values. - Parameter _ keys: A Dictionary of NSAttributedStringKey type keys and Any type values.
- Parameter range: A NSRange. - Parameter range: A NSRange.
*/ */
open func updateAttributes(_ stringKeys: [NSAttributedStringKey: Any], range: NSRange) { open func updateAttributes(_ keys: [NSAttributedStringKey: Any], range: NSRange) {
for (k, v) in stringKeys { for (k, v) in keys {
updateAttribute(k, value: v, range: range) updateAttribute(k, value: v, range: range)
} }
} }
/** /**
Removes a Dictionary of NSAttributedStringKeys for a given range. Removes a Dictionary of NSAttributedStringKeys for a given range.
- Parameter _ stringKeys: An Array of attributedStringKeys. - Parameter _ keys: An Array of attributedStringKeys.
- Parameter range: A NSRange. - Parameter range: A NSRange.
*/ */
open func removeAttributes(_ stringKeys: [NSAttributedStringKey], range: NSRange) { open func removeAttributes(_ keys: [NSAttributedStringKey], range: NSRange) {
for k in stringKeys { for k in keys {
removeAttribute(k, range: range) removeAttribute(k, range: range)
} }
} }
......
...@@ -40,8 +40,8 @@ extension UIFont { ...@@ -40,8 +40,8 @@ extension UIFont {
*/ */
open func stringSize(string: String, constrainedTo width: CGFloat) -> CGSize { open func stringSize(string: String, constrainedTo width: CGFloat) -> CGSize {
return string.boundingRect(with: CGSize(width: width, height: CGFloat(Double.greatestFiniteMagnitude)), return string.boundingRect(with: CGSize(width: width, height: CGFloat(Double.greatestFiniteMagnitude)),
options: NSStringDrawingOptions.usesLineFragmentOrigin, options: .usesLineFragmentOrigin,
attributes: [NSAttributedStringKey.font: self], attributes: [.font: self],
context: nil).size context: nil).size
} }
} }
...@@ -109,7 +109,7 @@ open class SearchBar: Bar { ...@@ -109,7 +109,7 @@ open class SearchBar: Bar {
open var placeholder: String? { open var placeholder: String? {
didSet { didSet {
if let v = placeholder { if let v = placeholder {
textField.attributedPlaceholder = NSAttributedString(string: v, attributes: [NSAttributedStringKey.foregroundColor: placeholderColor]) textField.attributedPlaceholder = NSAttributedString(string: v, attributes: [.foregroundColor: placeholderColor])
} }
} }
} }
...@@ -119,7 +119,7 @@ open class SearchBar: Bar { ...@@ -119,7 +119,7 @@ open class SearchBar: Bar {
open var placeholderColor = Color.darkText.others { open var placeholderColor = Color.darkText.others {
didSet { didSet {
if let v = placeholder { if let v = placeholder {
textField.attributedPlaceholder = NSAttributedString(string: v, attributes: [NSAttributedStringKey.foregroundColor: placeholderColor]) textField.attributedPlaceholder = NSAttributedString(string: v, attributes: [.foregroundColor: placeholderColor])
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment