色を変えるにはTextAttributesを利用します
lang
1 UIBarButtonItem* button = [[UIBarButtonItem alloc]initWithTitle:@"ボタン" style:UIBarButtonItemStyleDone target:self action:@selector(action)];
2
3 [button setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blueColor]} forState:UIControlStateNormal];
4
5 self.navigationItem.rightBarButtonItem = button;
NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle)
で下線も引けるはずですが、うまく動作しませんでした。
UIButtonを生成しUIBarbuttonとして入れ込む方法もあります
lang
1 UIButton*button2 = [UIButton buttonWithType:UIButtonTypeCustom];
2 NSAttributedString*title = [[NSMutableAttributedString alloc] initWithString:@"ボタン" attributes:@{NSForegroundColorAttributeName:[UIColor blueColor],NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle)}];
3 [button2 setAttributedTitle:title forState:UIControlStateNormal];
4 [button2 sizeToFit];
5 UIBarButtonItem*left = [[UIBarButtonItem alloc] initWithCustomView:button2];
6
7 self.navigationItem.leftBarButtonItem = left;
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。