2011-12-08 24 views
9

Olası Çoğalt:
UISegmentedControl selected segment color
UISegmentcontrol appearances causing issuesUISegmentcontrol yazı tipi ve seçili segment rengi nasıl değiştirilir?

Merhaba ben özel bir yazı varsayılan UISegmentControl yazı tipini değiştirebilir ve daha koyu yerine başka bir renge seçilen segmenti rengini değiştirmek gibi olacak renk.

sayesinde bu

enter image description here

düzenlemek için bu

enter image description here

den

: denilen Çözüm

// değişiklik yazı tipi boyutunu, gölge kaldırmak, seçilen metin & arka plan rengi normal durumdan farklı

-(void)defineSegmentControlStyle 
    { 
     //normal segment 
     NSDictionary *normalAttributes = [NSDictionary dictionaryWithObjectsAndKeys: 
            [UIFont fontWithName:@"Rok" size:20.0],UITextAttributeFont, 
            [UIColor colorWithRed:75.0/255.0 green:75.0/255.0 blue:75.0/255.0 alpha:1.0], UITextAttributeTextColor, 
            [UIColor clearColor], UITextAttributeTextShadowColor, 
            [NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowOffset, 
            nil];//[NSDictionary dictionaryWithObject: [UIColor redColor]forKey:UITextAttributeTextColor]; 
     [infoSegment setTitleTextAttributes:normalAttributes forState:UIControlStateNormal]; 

     NSDictionary *selectedAttributes = [NSDictionary dictionaryWithObjectsAndKeys: 
              [UIFont fontWithName:@"Rok" size:20.0],UITextAttributeFont, 
              [UIColor whiteColor], UITextAttributeTextColor, 
              [UIColor clearColor], UITextAttributeTextShadowColor, 
              [NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowOffset, 
              nil] ;//[NSDictionary dictionaryWithObject: [UIColor redColor]forKey:UITextAttributeTextColor]; 
     [infoSegment setTitleTextAttributes:selectedAttributes forState:UIControlStateSelected]; 

    } 
+0

http://stackoverflow.com/a/5932524/102937 –

cevap

1

Sen kontrol etmek isteyebilirsiniz bu: http://idevrecipes.com/2010/12/11/custom-segmented-controls/

+0

Cevabınız için teşekkürler, bununla birlikte özel bir yazı tipini ayarlamam gerektiğini gördüm ... – Desmond

+0

Belki bu? http://www.iphonedevsdk.com/forum/iphone-sdk-development/5059-change-font-size-text-uisegmentedcontrol.html –

+0

Seçili segmentin yazı tipi boyutunu UISegmentedControl içindeki seçili olmayanlardan farklı olarak değiştirmek mümkün müdür? Seçilen segmentin rengini değiştirebilirim ancak yazı tipi boyutunu değiştiremiyorum. – Shreyas

İlgili konular