evermeer / attributedtextview Goto Github PK
View Code? Open in Web Editor NEWEasiest way to create an attributed UITextView (with support for multiple links and from html)
License: Other
Easiest way to create an attributed UITextView (with support for multiple links and from html)
License: Other
Hi all,
Why it switches to TimesNewRomanPSMT font in Xcode 11?
Thanks
I know makeInteract uses 10.0 features. Is there a way to use this for iOS 9?
In The below example Anchor tags are detected as html link but not clickable
<a href='https://www.someurlink?username=12345'>Vivek Gupta
I used like below
self.descriptionLabel.attributer = text.html.matchHashtags.makeInteract({ [weak self] (hashTag) in
guard let slf = self else {return}
slf.delegate?.tappedLink(string: hashTag)
print(hashTag)
}).matchMentions.makeInteract({ [weak self] (mentionsText) in
guard let slf = self else {return}
slf.delegate?.tappedLink(string: mentionsText)
print(mentionsText)
}).matchLinks.font(BrandManager.currentStyle.typography.boldFont(pts: 12)).makeInteract({ [weak self] (linkText) in
guard let slf = self else {return}
slf.delegate?.tappedLink(string: linkText)
print(linkText)
}).font(UIFont.regularFont(pts: 12)).setLinkColor(.red)
the 'text' variable has html string.
Has anyone got this issue.
Please help.
I get user agreement from server and show it to user in UITextView with highlighted links. Last link is being highlighted incorrectly. After some research I discovered that problem cause "\r" symbol in text.
There are small code snippets that illustrate issue:
1
let rules = "http://serverurl.com/api.html"
textView.attributer = rules
.matchLinks.makeInteract({ link in
print("\(link)")
})
2
let rules = "http://serverurl.com/api.html\r\nhttp://serverurl.com/api2.html"
textView.attributer = rules
.matchLinks.makeInteract({ link in
print("\(link)")
})
Last character is not highlighted
3
let rules = "http://serverurl.com/api.html\r\nhttp://serverurl.com/api2.html\r\nhttp://serverurl.com/api3.html"
textView.attributer = rules
.matchLinks.makeInteract({ link in
print("\(link)")
})
Hello.
Please add a tag 1.4.1 for your latest version, to make git tag pinning in cocoa pods easier to prevent dependency confusion attacks.
Cheers!
Hi, basic question. If the api returns a string"Post your questions on our Pigeonhole link https://pigeonhole.at/learnhowtocode"
.. how can I match the entire https url?
In Swift 4.0 I am getting this error:
/Users/Pods/AttributedTextView/Sources/AttributedTextView.swift:83:44: Cannot convert value of type 'NSAttributedStringKey' to expected dictionary key type 'String'
Is there a way to set link colors differently in a single attributer?
This is the first (blue) link
and this one is the second (green) link
Thanks.
"".font(.systemFont(ofSize: 15))
cause crash
paragraphAlignRight is not working. Below I posted how I am using it.
textView.attributer = "by_clicking_tou_pp".white
.match(.terms_of_use).underline.makeInteract({ (link) in
print("TODO: open terms of user screen")
})
.match(.privacy_policy).underline.makeInteract({ (link) in
print("TODO: open privacy policy")
}).paragraphAlignRight
why not make makeInteract supported in UILabel? Can we extend it? or you planing to do so?
If the following UITextViewDelegate methods are not implemented they always return false. I think it would be much better if the return value was based on the TextView's isEditable property.
textViewShouldBeginEditing(_ textView: UITextView)
textViewShouldEndEditing(_ textView: UITextView)
textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String)
Hi, evermeer
I am going to develop a JSON formatting library based on this library.
s.dependency 'AttributedTextView', '~> 0.9'
When I tries to push the podspec file, a Xcode warning message was shown.
โ MGFormatter git:(master) pod trunk push MGFormatter.podspec
Updating spec repo `master`
CocoaPods 1.5.3 is available.
To update use: `sudo gem install cocoapods`
For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.5.3
Validating podspec
-> MGFormatter (0.1)
- WARN | xcodebuild: AttributedTextView/Sources/Attributer.swift:531:62: warning: 'substring(with:)' is deprecated: Please use String slicing subscript.
[!] The spec did not pass validation, due to 1 warning (but you can use `--allow-warnings` to ignore it).
The same thing happens in the travis CI, line 640
https://travis-ci.org/lm2343635/MGFormatter/builds/393497738?utm_source=github_status&utm_medium=notification
Is it possible you can help not enabling selection on textView when setting attributer ? In some scenario, text selection is really annoying and undesirable as we just want users be able to click and press (with textSelection enabled, it often pop up with some selected text when user long press)
It throws this in console:
dyld: Library not loaded: @rpath/AttributedTextView.framework/AttributedTextView
Referenced from: /var/containers/Bundle/Application/18F2B878-5571-48F9-A325-78A86B26B4C0/Demo.app/Demo
Reason: image not found
(lldb)
Assigning a new text to the attributer always changes the current values of the editable and selectable attributes as well. Is it really necessary to change the attributes in the attributer setter?
One can re-set those attributes after an assignment, but I would prefer not to do this all the time.
Is there any option of conditional append?? e.g, append some variable if it is not nil
Hello,
I need to have more fonts in one AttributedTextView instance. For example:
User1 followed ("myFontRegular") User2("myFontBold")
I tried it to implement in many ways, but I found out that only first font is applied to whole text in AttributedTextView. Here is sample of my implementation:
statusLabel.attributer =
name.color(.charcoal).font(.graphik(15))
.append(" followed ").color(.aluminium).font(.graphik(15))
.append("\(post.follow_display_name ?? "some user")").makeInteract({ _ in
if let followId = post.follow_user_id {
self.callback?(.user, followId)
}
})
.setLinkColor(.darkGreen).font(.graphikBold(15))
But result of this implementation is that whole text is in graphik font, not graphik and graphikBold. I tried to change sizes, and these are applied correctly, but different fons not. Is it somehow possible to achieve what I need by using AttributedTextView?
Thanks,
Vojta
Hello there,
This is i tried,
attributedTextView.attributer = decorate(7) { content in return (content + (
"The quick brown fox jumps over the lazy dog.\nPack my box with five dozen liquor jugs.\nSeveral fabulous dixieland jazz groups played with quick tempo.".brown
.match("brown fox").underline.makeInteract { (link) in
print("TODO: open terms of user screen")
}
.match("fabulous dixieland").underline(.patternDot).makeInteract { (link) in
print("TODO: open privacy policy")
}.all.paragraphAlignRight.paragraphApplyStyling
))
}
I'm trying applying light font like this:
let regular = UIFont.systemFont(ofSize: 15)
let light = UIFont.systemFont(ofSize: 15, weight: UIFontWeightLight)
label.attributedText = "regular ".font(regular)
.append("light").font(light)
.attributedText
But both words are with the same font (regular).
Hi there,
Seems like AttributedTextView.attributer.setter takes too much time while blocking main thread.
Is there anything we can do to make it faster? Seems like right now, it requires main thread, so I can't simply put in a background thread :(
let userName = "daurenmuratov"
let comment = "\(userName):"
.font(UIFont.systemFont(ofSize: 14, weight: .bold))
.match(userName)
.color(.black)
.makeInteract({ (userLogin) in
print("Login pressed: \(userLogin)")
})
+ (" \(text)")
.font(UIFont.systemFont(ofSize: 14))
.color(.gray)
.matchHashtags.color(.red)
.makeInteract({ (hashtag) in
print("Hashtag pressed: \(hashtag)")
})
.matchMentions
.makeInteract({ (mention) in
print("Mention pressed: \(mention)")
})
.matchLinks
.makeInteract({ (link) in
print("Link pressed \(link)")
})
.setLinkColor(.blue)
textView.attributer = comment
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.