回答編集履歴
1
アンダーラインに関する記述
    
        answer	
    CHANGED
    
    | @@ -1,10 +1,23 @@ | |
| 1 | 
            +
            色を変えるにはTextAttributesを利用します
         | 
| 1 2 |  | 
| 2 | 
            -
            TextAttributesを利用します
         | 
| 3 | 
            -
             | 
| 4 3 | 
             
            ```lang-objc
         | 
| 5 4 | 
             
                UIBarButtonItem* button = [[UIBarButtonItem alloc]initWithTitle:@"ボタン" style:UIBarButtonItemStyleDone target:self action:@selector(action)];
         | 
| 6 5 |  | 
| 7 | 
            -
                [button setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor  | 
| 6 | 
            +
                [button setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blueColor]} forState:UIControlStateNormal];
         | 
| 8 7 |  | 
| 9 8 | 
             
                self.navigationItem.rightBarButtonItem = button;
         | 
| 10 | 
            -
            ```
         | 
| 9 | 
            +
            ```
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle)
         | 
| 12 | 
            +
            で下線も引けるはずですが、うまく動作しませんでした。
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            UIButtonを生成しUIBarbuttonとして入れ込む方法もあります
         | 
| 15 | 
            +
            ```lang-objc
         | 
| 16 | 
            +
                UIButton*button2 = [UIButton buttonWithType:UIButtonTypeCustom];
         | 
| 17 | 
            +
                NSAttributedString*title = [[NSMutableAttributedString alloc] initWithString:@"ボタン" attributes:@{NSForegroundColorAttributeName:[UIColor blueColor],NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle)}];
         | 
| 18 | 
            +
                [button2 setAttributedTitle:title forState:UIControlStateNormal];
         | 
| 19 | 
            +
                [button2 sizeToFit];
         | 
| 20 | 
            +
                UIBarButtonItem*left = [[UIBarButtonItem alloc] initWithCustomView:button2];
         | 
| 21 | 
            +
                
         | 
| 22 | 
            +
                self.navigationItem.leftBarButtonItem = left;
         | 
| 23 | 
            +
            ```
         | 
