rootd / amattributedhighlightlabel Goto Github PK
View Code? Open in Web Editor NEW!!!DEPRECATED!!! A UILabel subclass with mention/hashtag/link highlighting.
!!!DEPRECATED!!! A UILabel subclass with mention/hashtag/link highlighting.
Right now the regex works for a very specific rule set which is often not enough for a particular situation (- in hashtags for example, or . in usernames)
Hello,
Thank you for amazing code.
i have a issue with RTL Languages, see the attach video please :)
Nothing more...
It's good practice to pick an unused class prefix for your stuff, but it's extremely important to not use class prefixes that Apple uses (http://developer.apple.com/library/ios/#documentation/cocoa/conceptual/ProgrammingWithObjectiveC/Conventions/Conventions.html). This looks good, but I don't want to publish it on Cocoa Controls until a new name is chosen, since publishing it now would result in 404s when the name does change.
does this still work
Got new issue here :
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSAttributedString invalid for autoresizing, it must have a single spanning paragraph style (or none) with a non-wrapping lineBreakMode.'
Do you know how to fix this?
I'm currently works with AMAttributedHighlightLabel, in some urls like this http://www.youtube.com/watch?v=iFNdGaN0P50 the regular expression has issues with some chars (in this case the question mark).
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"((@|#)([A-Z0-9a-z(é|ë|ê|è|à|â|ä|á|ù|ü|û|ú|ì|ï|î|í)_]+))|(http(s)?://([A-Z0-9a-z._-]*(/)?)*)" options:NSRegularExpressionCaseInsensitive error:&error];
I've found a new regex for fix this issue:
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"((@|#)([A-Z0-9a-z(é|ë|ê|è|à|â|ä|á|ù|ü|û|ú|ì|ï|î|í)_]+))|((?i)\\b((?:[a-z][\\w-]+:(?:/{1,3}|[a-z0-9%])|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,4}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:'\".,<>?«»“”‘’])))" options:NSRegularExpressionCaseInsensitive error:&error];
Hope this helps for someone.
As an enhancement, is it possible to provide support for chinese language? Please do reply.
does not work when there is line break in the string.
AMAttributedHighlightLabel has a bad performance when used in a table because the tappable areas get calculated every time the user scrolls. If you don't need tappable links in a table, simply comment out that part.
for(int i = 0;i < matchRange.length;i++)
{
CGRect pos = [self rectForLetterAtIndex:matchRange.location + i];
[touchableWords addObject:tappableWord];
[touchableWordsRange addObject:[NSValue valueWithRange:matchRange]];
[touchableLocations addObject:[NSValue valueWithCGRect:pos]];
}
Its not working when we simply post website name like www.github.com
There is code written for that but ,
NSTextCheckingResult *match = [regex firstMatchInString:word options:0 range:NSMakeRange(0, [word length])];
match will be nil when word start with www so its not going into below condition
if ([tappableWord length] > 0)
{
}
It will be great if someone can post the solution of it.
Thanks
All the resizing works ok, but the clicking of a mention, hashtag or url only works on the first line. I've checked the label background and that is correct the height.
Does AMAttributedHighlightLabel have any known issues with Purelayout?
Thanks in advance.
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.