IOS 5 Navigatsiya panelidagi tugmani rangini qanday o'zgartirish mumkin?

I want to change the color of back button of a navigation bar to make it look like thisenter image description here

13

5 javoblar

backBarButtonItem ning tintColor ni o'rnating:

self.navigationItem.backBarButtonItem.tintColor = [UIColor redColor];

TIP: If you want this to be applied to all UIBarButtonItem instances in your application by default, then you can use the new UIAppearance API to do just that:

[[UIBarButtonItem appearance] setTintColor:[UIColor redColor]];
63
qo'shib qo'ydi
@NileshTupe Men beradigan kodning boshqa satrini ishlatishingiz kerak. Bu kodni bosib o'tgan kontaktlarni boshqarish vositasida ishlash kerak.
qo'shib qo'ydi muallif Jacob Relkin, manba
Buni sinab ko'rdim - (void) viewDidLoad {[super viewDidLoad]; UIImageView * image = [[UIImageView alloc] initWithImage: [UIImage imageNamed: @ "logobar.png"]]; NSLog (@ "Frame ==% f", image.frame.size.width); self.navigationItem.backBarButtonItem.tintColor = [UIColor redColor]; self.navigationItem.titleView = tasvir; NSLog (@ "% f", self.navigationItem.titleView.frame.size.width); } lekin u ishlamayapti
qo'shib qo'ydi muallif Nilesh Tupe, manba
2-usulda Rahmat
qo'shib qo'ydi muallif Nilesh Tupe, manba
[[UIBarButtonItem ko'rinishi] setTintColor: [UIColor redColor]]; Ushbu usul iOS 5.0 versiyasida yoki undan past versiyalarda ishlashni qanday amalga oshirishi mumkin?
qo'shib qo'ydi muallif Nilesh Tupe, manba
Men bu kodni viewdidload usuliga joylashtirdim, ammo men buni hech qanday ta'sirga ega emas. Bu qatorni qaerga qo'yishim kerak?
qo'shib qo'ydi muallif Nilesh Tupe, manba
Chiziqli ko'rinish tekshiruvi ko'rinishidagiDidLoad birinchi qatorni qo'ymasligingiz kerak. Siz uni PUSHING view controllining viewDidLoad ko'rinishida joylashtirishingiz kerak va undan chiqarilgan barcha nazorat moslamalari to'g'ri orqaga qaytish tugmasiga ega bo'ladi.
qo'shib qo'ydi muallif Accatyyc, manba
Siz echim topdingizmi? Bunga erishishga harakat qilaman ...
qo'shib qo'ydi muallif Redwarp, manba

Jakobning birinchi qatori men uchun ishlamadi, chunki backBarButtonItem NULL edi. NULL, chunki u boshqa ViewController-ga o'tish vaqtida avtomatik ravishda yaratilgan. O'sha paytda siz tugmani sarlavha bilan belgilashingiz mumkin

self.title = @"nice title";//self is here the view(controller) within the popoverController

lekin tintColor-ni o'rnatolmaysiz.

Men uchun ishlagan narsa, yangi UIBarButtonItemni hech qanday uslubsiz yaratish edi. Keyin nom va rang xususiyatlarini o'rnating va uni backBarButtonItem sifatida o'rnating.

UIBarButtonItem *backButton = [[UIBarButtonItem alloc] init];
backButton.title = @"go back - now!";
backButton.tintColor = [UIColor colorWithRed:0.1 green:0.5 blue:0.7 alpha:1.0];
self.navigationItem.backBarButtonItem = backButton;
[okButton release];
8
qo'shib qo'ydi
Rahmat. U mukammal ishlaydi.
qo'shib qo'ydi muallif Philip007, manba

Agar siz tugmachani o'zingizning rasmingizga o'xshash qilib ko'rsatishni xohlasangiz, siz ham rasmdan foydalanishingiz mumkin:

[[UIBarButtonItem appearance] setBackButtonBackgroundImage:[UIImage imageNamed:@"back_button_bg"]
                                        forState:UIControlStateNormal
                                      barMetrics:UIBarMetricsDefault];

Yaxshi natijalarga erishish uchun fon tasvirini resizable tasvir bo'lishi kerak.

3
qo'shib qo'ydi
[[UINavigationBar appearance]setTintColor:[UIColor whiteColor]];

Bu men uchun harakat qilmoqda ...

1
qo'shib qo'ydi

Uni butun dunyo bo'ylab yoki mahalliy sifatida belgilashning eng yaxshi usuli

    [[UIBarItem appearance] setTitleTextAttributes:
         [NSDictionary dictionaryWithObjectsAndKeys:
         [UIColor colorWithRed:220.0/255.0 green:104.0/255.0 blue:1.0/255.0 alpha:1.0], UITextAttributeTextColor, 
         [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0], UITextAttributeTextShadowColor, 
         [NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowOffset, 
         [UIFont fontWithName:@"AmericanTypewriter" size:0.0], UITextAttributeFont, 
      nil] 
        forState:UIControlStateNormal];
0
qo'shib qo'ydi