0

I'm new to iOS/Objective-c and trying to allow the use to use underline and strike-thought text annotation but here is not a native font with this feature any way to add some kind of attribute?

NSDictionary *arial = [NSDictionary dictionaryWithObjectsAndKeys:@"ArialMT", [NSNumber numberWithInt:TextAnnotationFontStyleNone],
                                   @"Arial-BoldMT", [NSNumber numberWithInt:TextAnnotationStyleBold],
                                   @"Arial-ItalicMT", [NSNumber numberWithInt:TextAnnotationStyleItalic],
                                   @"Arial-BoldItalicMT", [NSNumber numberWithInt:TextAnnotationStyleBold | TextAnnotationStyleItalic],
                                   @"Arial-BoldMT", [NSNumber numberWithInt:TextAnnotationStyleUnderline], // ANY WAY TO ADD ANYTHING HERE TO MAKE IT UNDERLINE???
nil]; 
JProg
  • 189
  • 1
  • 9
  • 15

2 Answers2

1

Through NSFont you can control only font weight (i.e. bold it or not). Underlined and strike-through attributes are controlled via NSAttributedString (NSMutableAttributedString).

EXC_BAD_ACCESS
  • 346
  • 1
  • 4
  • 19
Nickolay Olshevsky
  • 13,706
  • 1
  • 34
  • 48
0

For underline and Strikethrough the texts in iOS you could use AttributedString. But AttributedString ffeature is achieved on iOS 6 version and not in lower versions.

For iOS lower than iOS-6 you can use ZAttributedStrings for underlining, strikethorugh or managing extra font effects.

There is a sample project code of iOS using ZAttributedString

Check this link of GitHub ZattributedString

Satish Azad
  • 2,302
  • 1
  • 16
  • 35