1

enter image description here

I have tried like this

#define KPrivacyText @"Your privacy is very important to us. We are committed \nto earn  your trust by safeguarding your personal \ninformation. All the information you provide to us is \nsecurely maintained and is kept strictly confidential. We \ndo not, and will not provide any personal information to \nyour organisation without your consent.\n\nThe governing principles: \n\n\n\u2022\tInformation is kept strictly confidential and secure. \n\n\n\u2022\tInformation is only used for the purposes stated.\n\n\n\u2022\tInformation is only shared with your consent."

_privacyText.text = KPrivacyText;

And I want "The governing principles:" in bold. Is there something like \n but for bold?

Rafael Tavares
  • 5,678
  • 4
  • 32
  • 48
Chandan Anand
  • 179
  • 1
  • 11

2 Answers2

4

You have to use NSAttributedText to achieve that.

NSString *boldFontName = [[UIFont boldSystemFontOfSize:12] fontName];
NSString *yourString = ...;
NSRange boldedRange = NSMakeRange(22, 4);

NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:yourString];

[attrString beginEditing];
[attrString addAttribute:kCTFontAttributeName 
                   value:boldFontName
                   range:boldedRange];

[attrString endEditing];
//draw attrString here...
Rafael Tavares
  • 5,678
  • 4
  • 32
  • 48
Mohamad Bachir Sidani
  • 2,077
  • 1
  • 11
  • 17
2

I used NSMutableAttributedString.

- (void)viewDidLoad {
    [super viewDidLoad];
    _isPolicyAccepted = NO;
    //_privacyText.text = KPrivacyText;
    self.title = @"Privacy Policy";

    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"Your privacy is very important to us. We are committed \nto earn  your trust by safeguarding your personal \ninformation. All the information you provide to us is \nsecurely maintained and is kept strictly confidential. We \ndo not, and will not provide any personal information to \nyour organisation without your consent.\n\nThe governing principles: \n\n\u2022\tInformation is kept strictly confidential and secure. \n\n\u2022\tInformation is only used for the purposes stated.\n\n\u2022\tInformation is only shared with your consent."];
    [attributedString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:13.0f weight:UIFontWeightBold] range:NSMakeRange(318, 27)];
    
    _privacyText.attributedText=attributedString;
}
Rafael Tavares
  • 5,678
  • 4
  • 32
  • 48
Chandan Anand
  • 179
  • 1
  • 11