5
cell!.textLabel?.text = vehicle["vrn"].string
cell?.detailTextLabel?.text = stateString

I want to display stateString as bold and also tried to use textLabel instead of detailedText but it did not work.

TylerH
  • 20,799
  • 66
  • 75
  • 101
Raj
  • 61
  • 3
  • 7

3 Answers3

5

You can set the font property of the detailTextLabellike so:

cell.detailTextLabel?.font = UIFont.boldSystemFontOfSize(15.0)
pbush25
  • 5,228
  • 2
  • 26
  • 35
  • Answer is incorrect, you need to set the .font property not the .text – Raj Jul 30 '15 at 15:00
  • correct answer: cell?.detailTextLabel?.textColor = UIColor.blackColor() – Raj Jul 30 '15 at 15:23
  • You're right, it should be font, not text, my bad. But just setting the text color to black doesn't make it bold... – pbush25 Jul 30 '15 at 15:26
5

You can use the font property inside the UILabel class.

// You need to set the name of your font here 
cell.detailTextLabel?.font = UIFont(name:"HelveticaNeue-Bold", size: 16.0)

There are other options using the attributedText property but implies a little more of code, something like this:

// Define attributes to set
let labelFont = UIFont(name: "HelveticaNeue-Bold", size: 16)
let attributes :Dictionary = [NSFontAttributeName : labelFont]

// Create the attributed string
var attrString = NSAttributedString(string: "textOfYourLabel", attributes:attributes)
cell.detailTextLabel?.attributedText = attrString

I hope this help you.

Victor Sigler
  • 23,243
  • 14
  • 88
  • 105
0

If you want to bold text label using story board, simply select SHADOW colour in attributes inspector to same of that Text colour. Its works for me try it....

sachin
  • 153
  • 4
  • 18