0

次のコードを使用してツールバー ボタンを作成しています....テキストの色を黒またはそれ以上に変更したいのですが...背景画像をテキストの色に設定します.....setBackgroundColor は機能しません.. ..どんな助けでも大歓迎です、ありがとう。

UIButton *btnEditLogin = [UIButton buttonWithType:UIButtonTypeCustom];
   [btnEditLogin setBackgroundImage:[UIImage imageNamed:@"btnPlain.png"] forState:UIControlStateNormal];
   [btnEditLogin setTitle:@"Edit Login" forState:UIControlStateNormal];
   [btnEditLogin setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
   btnEditLogin.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:12.0f];
   [btnEditLogin.layer setCornerRadius:5.0f];
   [btnEditLogin.layer setMasksToBounds:YES];
   [btnEditLogin.layer setBorderWidth:1.0f];
   [btnEditLogin.layer setBorderColor: [[UIColor brownColor] CGColor]];
   btnEditLogin.frame=CGRectMake(0.0, 100.0, 90.0, 30.0);
   [btnEditLogin addTarget:self action:@selector(LoginBtn) forControlEvents:UIControlEventTouchUpInside];
   UIBarButtonItem *editLoginItem = [[UIBarButtonItem alloc] initWithCustomView:btnEditLogin];
4

2 に答える 2

0

NavigationItem の titleView 属性を使用するだけで、必要なことを実行できます。次のことができます。

UILabel *myLabel = [... enter all the code you want to customize the text, etc here];
self.navigationcontroller.navigationitem.titleView = myLabel;

そして、あなたは終わったはずです...私が質問を誤解していない限り。

于 2012-07-26T18:10:11.680 に答える
0

このコードを使用して、ツールバーのテキストの色を変更します。

UIBarButtonItem *barButtonAppearance = [UIBarButtonItem appearance];
[barButtonAppearance setTintColor:[UIColor redColor]];
于 2016-06-09T09:47:58.777 に答える