Is there any way to bold only part of a string? For example:
Approximate Distance: 120m away
Thanks!
What you could do is use an NSAttributedString
.
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...
Take a look at this handy dandy guide to drawing NSAttributedString
objects with Core Text.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With