2011-12-08 50 views
9

thể trùng lặp:
UISegmentedControl selected segment color
UISegmentcontrol appearances causing issuesLàm cách nào để thay đổi phông chữ UISegmentcontrol và màu phân đoạn đã chọn?

Hi tôi sẽ muốn thay đổi phông chữ UISegmentControl mặc định cho một phông chữ tùy chỉnh và thay đổi màu phân khúc được lựa chọn màu khác thay vì một tối màu.

nhờ

từ này

enter image description here

để

enter image description here

EDIT này: Giải pháp gọi

01.235.kích thước

// thay đổi font chữ, loại bỏ bóng, chọn màu nền văn bản & khác với trạng thái bình thường

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

Trả lời

1

Bạn có thể muốn kiểm tra này: http://idevrecipes.com/2010/12/11/custom-segmented-controls/

+0

cảm ơn vì đã trả lời, tôi thấy rằng tuy nhiên tôi cũng cần đặt phông chữ tùy chỉnh ... – Desmond

+0

Có lẽ đây không? http://www.iphonedevsdk.com/forum/iphone-sdk-development/5059-change-font-size-text-uisegmentedcontrol.html –

+0

Có thể thay đổi kích thước phông chữ của phân khúc được chọn khác với kích thước không được chọn trong UISegmentedControl không? Tôi có thể thay đổi Màu của phân đoạn đã chọn nhưng không thay đổi kích thước phông chữ. – Shreyas

Các vấn đề liên quan