2016-08-10 5 views
4

は、私は、この画像のように、ナビゲーションバーの「完了」ボタンの色を設定したい:私はself.doneButton.enabled = NO;ようなコードを設定しましたが、完了ボタンはまだ白い色をしている、がナビゲーションバーに色 `rightBarButtonItem`を設定するには?

enter image description here

。画像のように色が変わることはありません。

上記の画像の[完了]ボタンのように、テキストの色を変更するコードを設定するにはどうすればよいですか? この問題を解決するのを手伝ってください。私はあなたの助けに感謝します。変更の

+0

を試してみてください? o_O –

答えて

1

ボタンを無効にした後、次の行を追加する(ただし、テストされていない)に役立ち得る

self.navigationItem.rightBarButtonItem.tintColor = [UIColor lightGrayColor]; 
4

barbutton使用の色

対物C

self.navigationItem.rightBarButtonItem = yourRightbarbuttonName; 
self.navigationItem.rightBarButtonItem.tintColor = [UIColor blueColor]; // add your color 

スウィフト

か、する場合はストーリーボード Set bat button color

self.navigationItem.rightBarButtonItem = yourRightbarbuttonName 
self.navigationItem.rightBarButtonItem.tintColor = UIColor.blueColor() 

から設定は

客観C

self.navigationItem.rightBarButtonItem.enabled = YES; 

スウィフト

右barbutton
使用することを示して
self.navigationItem.rightBarButtonItem.enabled = true 

あなたがする場合は

右barbutton使用を隠す目的C

self.navigationItem.rightBarButtonItem.enabled = NO; 

スウィフト

self.navigationItem.rightBarButtonItem.enabled = false 
1

あなたはXIB /ストーリーボードなどから、それを設定することができます画像に示されている

または、barbuttonアイテムのtintColorプロパティを設定できます。

0

私をサポートしていただきありがとうございます。私もあなたのようなコードを変更しますが、 "完了"ボタンのテキストの色は変更できません。今、私はこの問題の良い解決策を見つけました。

まず、私はそのような一般的な機能の作成:

- (void)changeStatusOfRightBarButton:(BOOL)enabled withColorAlpha:(CGFloat)numberAlpha { 
    _doneButton.enabled = enabled; 
    [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] 
    setTitleTextAttributes: 
    @{NSForegroundColorAttributeName:[UIColor colorWithHexString:@"FFFFFF" alpha:numberAlpha], 
    NSFontAttributeName:[UIFont fontAvenirNextRegularWithSize:15.0f] 
    } 
    forState:UIControlStateNormal]; 

}

を第二私はそのようなviewDidloadにそれを適用する:

if (self.noteTextView.text.length == 0) { 
    [self.noteTextView becomeFirstResponder]; 
    [self changeStatusOfRightBarButton:NO withColorAlpha:0.44f]; 

}

Iこれらのコードを適用する「完了」ボタンの色が変わった。

1

は、使用しているどのようなフォントこの

UIBarButtonItem *rightBarButton=[[UIBarButtonItem alloc]initWithTitle:@"Done" style:UIBarButtonItemStylePlain target:self action:@selector(editProfileClick)]; 
rightBarButton.tintColor=[UIColor whiteColor]; 
self.navigationItem.rightBarButtonItem = rightBarButton; 


-(void)editProfileClick 
{ 
//your methods 
} 
関連する問題