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
để
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];
}
http://stackoverflow.com/a/5932524/102937 –