SORU
3 Mayıs 2012, PERŞEMBE


Nasıl UİNavigationBar iOS5 görünümünü kullanarak, başlık yazı tipi ve renk API ayarlamak için?

Birden çok Görünümü Denetleyicileri var ve kırmızı tüm yazı tipi rengini ayarlamak istiyorum.

 [[UINavigationBar appearance] setFont:[UIFont boldSystemFontOfSize:12.0]];

olduğunu tanınmayan seçici bir hata atma.

lütfen bir kod, aşağıdaki düzeltme işlemi yapmak.

CEVAP
3 Mayıs 2012, PERŞEMBE


Ray Wenderlich:

http://www.raywenderlich.com/4344/user-interface-customization-in-ios-5

// Customize the title text for *all* UINavigationBars
[[UINavigationBar appearance] setTitleTextAttributes:
    [NSDictionary dictionaryWithObjectsAndKeys:
        [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0], 
        UITextAttributeTextColor, 
        [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8], 
        UITextAttributeTextShadowColor, 
        [NSValue valueWithUIOffset:UIOffsetMake(0, -1)], 
        UITextAttributeTextShadowOffset, 
        [UIFont fontWithName:@"Arial-Bold" size:0.0], 
        UITextAttributeFont, 
        nil]];

Ya da eğer bir nesne değişmez tarzı ile tercih ederseniz:

[[UINavigationBar appearance] setTitleTextAttributes:@{
    UITextAttributeTextColor: [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0],
    UITextAttributeTextShadowColor: [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8],
    UITextAttributeTextShadowOffset: [NSValue valueWithUIOffset:UIOffsetMake(0, -1)],
    UITextAttributeFont: [UIFont fontWithName:@"Arial-Bold" size:0.0],
}];

Ve aşağıdaki iOS 7 için düzenleyin

UİTextAttributes aşağıdaki kullanabilirsiniz iOS 7 olarak iptal etme

NSShadow *shadow = [[NSShadow alloc] init];
shadow.shadowColor = [UIColor colorWithWhite:.0f alpha:1.f];
shadow.shadowOffset = CGSizeMake(0, -1);

[[UINavigationBar appearance] setTitleTextAttributes:@{
     NSForegroundColorAttributeName: [UIColor whiteColor],
     NSShadowAttributeName: shadow,
     NSFontAttributeName: [UIFont fontWithName:@"Arial-Bold" size:15.0f]
     }];

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • InfoPuppet

    InfoPuppet

    15 Kasım 2011
  • Jonathan Morrison

    Jonathan Mor

    24 Mart 2010
  • MandMEvangelists

    MandMEvangel

    28 Ocak 2008