To be precise, this can be done as below
[buttonItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont fontWithName:@"Helvetica-Bold" size:26.0], NSFontAttributeName,
[UIColor greenColor], NSForegroundColorAttributeName,
nil]
forState:UIControlStateNormal];
Or with object literal syntax:
[buttonItem setTitleTextAttributes:@{
NSFontAttributeName: [UIFont fontWithName:@"Helvetica-Bold" size:26.0],
NSForegroundColorAttributeName: [UIColor greenColor]
} forState:UIControlStateNormal];
For convenience, here's the Swift implementation:
buttonItem.setTitleTextAttributes([
NSAttributedStringKey.font: UIFont(name: "Helvetica-Bold", size: 26.0)!,
NSAttributedStringKey.foregroundColor: UIColor.green],
for: .normal)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…