Write the following text in the label “Bold Regular”Double Click on Bold to select it, and then right click on it to see more options. Select font > Bold from that option. It should do the task.
Easy! Double-tap a word to highlight it and drag the indicators to select multiple words if you want. Then, a menu will pop up. Tap "BIU" here, then select from one of the four options: Bold, Italic, Underline, or Strikethrough.
To make text bold, select and highlight the text first. Then hold down Ctrl (the control key) on the keyboard and press B on the keyboard. To make text italic, select and highlight the text first. Then hold down Ctrl (the control key) on the keyboard and then press the I on the keyboard.
Don't try to play with the font names. Using the font descriptor you need no names:
UILabel * label = [[UILabel alloc] init]; // use your label object instead of this
UIFontDescriptor * fontD = [label.font.fontDescriptor
fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitBold
| UIFontDescriptorTraitItalic];
label.font = [UIFont fontWithDescriptor:fontD size:0];
size:0
means 'keep the size as is'
With Swift try the following extension:
extension UIFont {
func withTraits(traits:UIFontDescriptorSymbolicTraits...) -> UIFont {
let descriptor = self.fontDescriptor()
.fontDescriptorWithSymbolicTraits(UIFontDescriptorSymbolicTraits(traits))
return UIFont(descriptor: descriptor, size: 0)
}
func boldItalic() -> UIFont {
return withTraits(.TraitBold, .TraitItalic)
}
}
Then you may use it this way:
myLabel.font = myLabel.font.boldItalic()
or even add additional traits like Condensed:
myLabel.font = myLabel.font.withTraits(.TraitCondensed, .TraitBold, .TraitItalic)
extension UIFont {
var bold: UIFont {
return with(traits: .traitBold)
} // bold
var italic: UIFont {
return with(traits: .traitItalic)
} // italic
var boldItalic: UIFont {
return with(traits: [.traitBold, .traitItalic])
} // boldItalic
func with(traits: UIFontDescriptorSymbolicTraits) -> UIFont {
guard let descriptor = self.fontDescriptor.withSymbolicTraits(traits) else {
return self
} // guard
return UIFont(descriptor: descriptor, size: 0)
} // with(traits:)
} // extension
Use it as follows:
myLabel.font = myLabel.font.bold
or
myLabel.font = myLabel.font.italic
or
myLabel.font = myLabel.font.with(traits: [ .traitBold, .traitCondensed ])
extension UIFont {
var bold: UIFont {
return with(.traitBold)
}
var italic: UIFont {
return with(.traitItalic)
}
var boldItalic: UIFont {
return with([.traitBold, .traitItalic])
}
func with(_ traits: UIFontDescriptor.SymbolicTraits...) -> UIFont {
guard let descriptor = self.fontDescriptor.withSymbolicTraits(UIFontDescriptor.SymbolicTraits(traits).union(self.fontDescriptor.symbolicTraits)) else {
return self
}
return UIFont(descriptor: descriptor, size: 0)
}
func without(_ traits: UIFontDescriptor.SymbolicTraits...) -> UIFont {
guard let descriptor = self.fontDescriptor.withSymbolicTraits(self.fontDescriptor.symbolicTraits.subtracting(UIFontDescriptor.SymbolicTraits(traits))) else {
return self
}
return UIFont(descriptor: descriptor, size: 0)
}
}
sectionLabel.font = [UIFont fontWithName:@"TrebuchetMS-Bold" size:18];
There is a list of font names that you can set in place of 'fontWithName' attribute.The link is here
@Edinator have a look on this..
myLabel.font = [UIFont boldSystemFontOfSize:16.0f]
myLabel.font = [UIFont italicSystemFontOfSize:16.0f];
use any one of the above at a time you want
You can set any font style, family, size for the label, by clicking on letter "T" in Font field.
Swift 3
Bold:
let bondFont = UIFont.boldSystemFont(ofSize:UIFont.labelFontSize)
Italic:
let italicFont = UIFont.italicSystemFont(ofSize:UIFont.labelFontSize)
I have the same issue that need to apply both Bold and Italic on a label and button. You can simply use following code to achieve this effect:
myLabel.font = [UIFont fontWithName:@"Arial-BoldItalic" size:30.0];
With iOS 7 system default font, you'll be using helvetica neue bold if you are looking to keep system default font.
[titleText setFont:[UIFont fontWithName:@"HelveticaNeue-Bold" size:16.0]];
Or you can simply call it:
[titleText setFont:[UIFont boldSystemFontOfSize:16.0]];
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