mild updates.

This commit is contained in:
Kevin G Christiano 2019-09-23 12:43:52 -04:00
parent 4770aa6e6b
commit d0797a4825

View File

@ -115,7 +115,7 @@ public typealias ActionBlock = () -> ()
standardFontSize = size standardFontSize = size
} }
/// Convenience to init Label with the link comprised of range, actionMap and delegateObject /// Convenience to init Label with a link comprised of range, actionMap and delegateObject
@objc convenience public init(text: String, range: NSRange, actionMap: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) { @objc convenience public init(text: String, range: NSRange, actionMap: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) {
self.init() self.init()
self.text = text self.text = text
@ -555,7 +555,7 @@ extension Label {
} }
} }
// MARK: - Multi-Action Functionality // MARK: - Multi-Link Functionality
extension Label { extension Label {
/// Applied to existing text. Removes underlines of tappable links and assoated actionable clauses. /// Applied to existing text. Removes underlines of tappable links and assoated actionable clauses.
@ -582,7 +582,7 @@ extension Label {
} }
} }
func addActionAttributes(range: NSRange, string: NSMutableAttributedString?) { private func addActionAttributes(range: NSRange, string: NSMutableAttributedString?) {
guard let string = string else { return } guard let string = string else { return }
string.addAttributes([NSAttributedString.Key.underlineStyle: NSUnderlineStyle.single.rawValue], range: range) string.addAttributes([NSAttributedString.Key.underlineStyle: NSUnderlineStyle.single.rawValue], range: range)
@ -625,6 +625,7 @@ extension Label {
} }
} }
/// Converts the entire text into a link. All characters will be underlined and the intrinsic bounds will respond to tap.
@objc public func makeTextButton(actionMap: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) { @objc public func makeTextButton(actionMap: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) {
if let actionBlock = createActionBlockFor(actionMap: actionMap, additionalData: additionalData, delegateObject: delegateObject) { if let actionBlock = createActionBlockFor(actionMap: actionMap, additionalData: additionalData, delegateObject: delegateObject) {
@ -632,6 +633,7 @@ extension Label {
} }
} }
/// Converts the entire text into a link. All characters will be underlined and the intrinsic bounds will respond to tap.
@objc public func makeTextButton(actionBlock: @escaping ActionBlock) { @objc public func makeTextButton(actionBlock: @escaping ActionBlock) {
setTextLinkState(range: getRange, actionBlock: actionBlock) setTextLinkState(range: getRange, actionBlock: actionBlock)
@ -647,7 +649,6 @@ extension Label {
@objc private func textLinkTapped(_ gesture: UITapGestureRecognizer) { @objc private func textLinkTapped(_ gesture: UITapGestureRecognizer) {
for clause in clauses { for clause in clauses {
// This determines if we tapped on the desired range of text. // This determines if we tapped on the desired range of text.
if let range = clause.range, gesture.didTapAttributedTextInLabel(self, inRange: range) { if let range = clause.range, gesture.didTapAttributedTextInLabel(self, inRange: range) {
clause.performAction() clause.performAction()