2011-12-08 20 views
9

Duplicar posible:
UISegmentedControl selected segment color
UISegmentcontrol appearances causing issues¿Cómo cambiar la fuente UISegmentcontrol y el color del segmento seleccionado?

Hola me gustaría cambiar la fuente predeterminada UISegmentControl a una fuente personalizada y cambiar el color segmento seleccionado a otro color en lugar de una más oscura color.

gracias

de esta

enter image description here

a este

enter image description here

EDIT: Solución llamada

tamaño

// cambiar la fuente, quitar la sombra, texto & color de fondo seleccionado son diferentes de estado normal

-(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 –

Respuesta

1

Es posible que desee echa un vistazo a esto: http://idevrecipes.com/2010/12/11/custom-segmented-controls/

+0

gracias por la respuesta, vi que, sin embargo, también tengo que configurar una fuente personalizada ... – Desmond

+0

¿Quizás esto? http://www.iphonedevsdk.com/forum/iphone-sdk-development/5059-change-font-size-text-uisegmentedcontrol.html –

+0

¿Es posible cambiar el tamaño de fuente del segmento seleccionado diferente de los no seleccionados en UISegmentedControl? Puedo cambiar el Color del segmento seleccionado pero no el tamaño de la fuente. – Shreyas

Cuestiones relacionadas