Vì vậy, tôi đã cố gắng thay đổi thuộc tính văn bản của tiêu đề của UISegmentedControl của tôi, nhưng nó không hoạt động, không có gì thay đổi. Tôi cũng đã áp dụng nền tùy chỉnh và dải phân cách và nó hoạt động chính xác, nhưng không áp dụng điều này.UISegmentedControl setTitleTextAttributes không hoạt động
NSDictionary *normaltextAttr =
@{[UIColor blackColor]: UITextAttributeTextColor,
[UIColor clearColor]: UITextAttributeTextShadowColor,
[UIFont fontWithName:_regularFont size:20.f]: UITextAttributeFont};
NSDictionary *selectedtextAttr =
@{[UIColor colorWithRed:135.0/255.0 green:135.0/255.0 blue:135.0/255.0 alpha:1.0]: UITextAttributeTextColor,
[UIColor clearColor]: UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, 1)]: UITextAttributeTextShadowOffset,
[UIFont fontWithName:_regularFont size:0.0]: UITextAttributeFont};
[[UISegmentedControl appearance] setTitleTextAttributes:normaltextAttr
forState:UIControlStateNormal];
[[UISegmentedControl appearance] setTitleTextAttributes:selectedtextAttr
forState:UIControlStateSelected];
hoạt động! vì vậy phương pháp này không thích từ điển nghĩa đen? – harinsa
Từ điển nghĩa đen hoạt động tốt; nếu không, sẽ có một lỗi nghiêm trọng trong iOS! '[self setTitleTextAttributes: @ {UITextAttributeTextColor: [UIColorAolorolor]} forState: UIControlStateNormal]; ' – NathanAldenSr
Sẽ rất tuyệt nếu câu trả lời chỉ ra điều gì sai trái thay vì chỉ đăng một thứ gì đó hoạt động. –