66

I want to make UILabel's text bold

infoLabel=[[UILabel alloc]initWithFrame:CGRectMake(90,150, 200, 30)];
[infoLabel setText:@"Drag 14 more Flavors"];
[infoLabel setBackgroundColor:[UIColor clearColor]];
[infoLabel setFont:[UIFont fontWithName:@"Arial" size:16]];

[infoLabel setTextColor:[UIColor colorWithRed:193.0/255 
                                        green:27.0/255 
                                         blue:23.0/255 
                                        alpha:1 ]];
Cœur
  • 37,241
  • 25
  • 195
  • 267
Ali
  • 10,774
  • 10
  • 56
  • 83

6 Answers6

133

If you want to retain the system font and make it bold:

[infoLabel setFont:[UIFont boldSystemFontOfSize:16]];
Manny
  • 6,277
  • 3
  • 31
  • 45
  • 2
    And if you want to retain the size: [infoLabel setFont:[UIFont boldSystemFontOfSize: infoLabel.font.pointSize]]; – narco Sep 05 '17 at 10:45
69

Try

[infoLabel setFont:[UIFont fontWithName:@"Arial-BoldMT" size:16]];

It may also be worth checking if the font you're trying to use is available on device

Vladimir
  • 170,431
  • 36
  • 387
  • 313
  • 6
    It would be nice to merge this answer and the one below: If you want to retain the system font and make it bold: [infoLabel setFont:[UIFont boldSystemFontOfSize:16]]; – Jasper Blues Jul 20 '12 at 00:46
44

Using the GUI in Xcode select the label then go to the Attributes Inspector. One of the options is Font. Click on the font icon (not the up-down arrows). In the popup that appears expand the Font ComboxBox. Under the Bold System section choose Regular.

Xcode screenshot

2Yootz
  • 3,971
  • 1
  • 36
  • 31
17

For swift users this should work:

myLabel.font = UIFont.boldSystemFont(ofSize: 12.0)

or if you'd like to use a different font:

myLabel.font = UIFont(name:"HelveticaNeue-Bold", size: 12.0)
spencer.sm
  • 19,173
  • 10
  • 77
  • 88
Nyakiba
  • 862
  • 8
  • 18
6

Where possible I would suggest using dynamic font sizes to provide the best possible accessibility to your users.

You can make a label use a system dynamic font and set it to have bold text by doing the following:

 exampleLabel.font = UIFont.preferredFont(forTextStyle: .body, compatibleWith: UITraitCollection(legibilityWeight: .bold))
Edward
  • 2,864
  • 2
  • 29
  • 39
  • I tried this just for fun ... didn't work. – LukeSideWalker Dec 30 '21 at 13:37
  • Worked for me. That having been said, when I want to use custom fonts/styles in my app, but want it to size dynamically, I often use [`scaledFont`](https://developer.apple.com/documentation/uikit/uifontmetrics/2877385-scaledfont). E.g., `UIFontMetrics.default.scaledFont(for: customFont)`. – Rob Apr 13 '23 at 18:17
  • But, fundamentally, I think this answer is correct, that one should almost never use fixed font sizes within an app. Dynamic type is the way to go! – Rob Apr 13 '23 at 18:26
0

You can set the stroke with a negative value to make a bold effect if you don't have the bold variation of your custom font. See here:

How can I both stroke and fill with NSAttributedString w/ UILabel

Community
  • 1
  • 1
Ferran Maylinch
  • 10,919
  • 16
  • 85
  • 100