ios - How to underline part of string with NSAttributedString objective-c -


Only works under a string when the range starts with zero. If I start it on 1, it works if the green color works

  + (NSAttributedString *) returnNSAttributedString: (NSString *) String Range: WithColour (NSRange) : (UIColor *) Color WithUnderLine: (bool) graphs {NSMutableAttributedString * attributedString = [[NSMutableAttributedString alloc] InitWithString: string]; If (underline) {[attributedString addAttributes: @ {NSUnderlineStyleAttributeName: @ (NSUnderlineStyleSingle)} border: border]; } [AttributedString addAttribute: NSForegroundColorAttributeName Value: Color Range: Category]; [AttributedString addAttribute: NSForegroundColorAttributeName Price: [UIColor redColor] Range: NSRangeFromString (string)]; Return stroke; }  

It does not work on iOS 7

After

You can use the NSUnderlineStyleAttributeName and NSUnderlineColorAttributeName attributes. You can use it like this:

  NSRange foundRange = [wordString rangeOfString: @ "base mix"]; If (foundRange.location! = NSNotFound) {[starting word string]; [WordString addAttribute: NSUnderlineStyleAttributeName Value: [NSNumber numberWithInt: 1] Range: foundRange]; [Word String addAttribute: NSUnderlineColorAttributeName Value: [NSColor redColor] Category: foundRange]; [Word string and ading]; }  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -