Objective-C:
NSUInteger fontSize = 20;
UIFont *font = [UIFont boldSystemFontOfSize:fontSize];
NSDictionary *attributes = @{NSFontAttributeName: font};
UIBarButtonItem *item = [[UIBarButtonItem alloc] init];
[item setTitle:@"Some Text"];
[item setTitleTextAttributes:attributes forState:UIControlStateNormal];
self.navigationItem.rightBarButtonItem = item;
Swift:
let fontSize:CGFloat = 20;
let font:UIFont = UIFont.boldSystemFont(ofSize: fontSize);
let attributes:[String : Any] = [NSFontAttributeName: font];
let item = UIBarButtonItem.init();
item.title = "Some Text";
item.setTitleTextAttributes(attributes, for: UIControlState.normal);
self.navigationItem.rightBarButtonItem = item;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…