Closed etoledom closed 6 years ago
(Suggestions!!)
extension NSMutableAttributedString {
private var foundationString: NSString {
return string as NSString
}
func linkify(anchorText: String, link: String) {
var range = foundationString.range(of: anchorText)
while range.location != NSNotFound {
addAttribute(.link, value: link, range: range)
let minimumRange = NSRange(location: range.location + 1, length: foundationString.length - range.location - 1)
range = foundationString.range(of: anchorText, options: .caseInsensitive, range: minimumRange)
}
}
}
let test = NSMutableAttributedString(string: "Automattic Company Testing", attributes: nil)
test.linkify(anchorText: "Company", link: "http://www.a8c.com")
--
Squirrel still stands, this can be improved whenever the WPNoResults replacement is in place!
We decided to add those improvements to the new NoResultsViewController
Meanwhile, I added a comment to the attributedMessageText
property explaining intention and behavior.
Thank you @jleandroperez !
This PR adds support for attributes in the WPNoResultsView's message 'label'. This is used to show a tappable link in the Stock Photos feature in the Main WPiOS app.
These changes where already reviewed and accepted here, but since we were working in a feature branch, this changes didn't make it to develop on time.
This is a re-implementation of those changes so they are accessible in the feature branch after updating with develop in the main WPiOS project.