Wednesday, February 11, 2015

NSMutableString to set some part of sting BOLD -- IOS

 NSString *textStr = @"This is a good boy";

NSRange rangeBold = [textStr rangeOfString:@"good"];

 UIFont *changeFont = [UIFont boldSystemFontOfSize:13];
        
  NSDictionary *dictBoldText = [NSDictionary dictionaryWithObjectsAndKeys: changeFont, NSFontAttributeName, nil];
        
 NSMutableAttributedString *mutAttrTextViewString = [[NSMutableAttributedString alloc] initWithString:textStr];
        
  [mutAttrTextViewString setAttributes:dictBoldText range:rangeBold];

        
       

    YOUR_TEXT_VIEW.attributedText = mutAttrTextViewString;

No comments:

Post a Comment