How to make text bold for detailTextLabel in swift

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

      

I want to show stateString

how bold

and also tried using textLabel

instead detailedText

, but it didn't work.

+3


source to share


3 answers


You can use the property font

inside the class UILabel

.

// 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 property attributedText

, but implies a little more 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

      

Hope this helps you.

+3


source


You can set the font property detailTextLabel

like this:



cell.detailTextLabel?.font = UIFont.boldSystemFontOfSize(15.0)

      

+2


source


If you want a bold text label using the story bar, simply select the SHADOW color from the attribute index of that text's same color. His works for me are trying ...

0


source







All Articles