次のコードを使用して UISegmentedControl の外観を設定しました。
UIImage *segmentSelected = [[UIImage imageNamed:@"Segment_Unselected.png"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 12, 0, 12)];
UIImage *segmentUnselected = [[UIImage imageNamed:@"Segment_Selected.png"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 12, 0, 12)];
[[UISegmentedControl appearance] setBackgroundImage:segmentUnselected
forState:UIControlStateNormal
barMetrics:UIBarMetricsDefault];
[[UISegmentedControl appearance] setBackgroundImage:segmentSelected
forState:UIControlStateSelected
barMetrics:UIBarMetricsDefault];
[[UISegmentedControl appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithRed:77.0/255.0 green:45.0/255.0 blue:8.0/255.0 alpha:1],UITextAttributeTextColor,
[UIColor clearColor], UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, 0)], UITextAttributeTextShadowOffset,
[UIFont fontWithName:@"HelveticaNeue-Bold" size:16.0], UITextAttributeFont, nil] forState:UIControlStateNormal];
[[UISegmentedControl appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor],UITextAttributeTextColor,
[UIColor clearColor], UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, 0)], UITextAttributeTextShadowOffset,
[UIFont fontWithName:@"HelveticaNeue-Bold" size:16.0], UITextAttributeFont, nil] forState:UIControlStateSelected];
[[UISegmentedControl appearance] setDividerImage:[UIImage imageNamed:@"SegmentedControl_Divider.png"]
forLeftSegmentState:UIControlStateNormal
rightSegmentState:UIControlStateNormal
barMetrics:UIBarMetricsDefault];
そして私は完璧な出力を得ました
しかし、今はUISegmentのデフォルトの外観を設定したい
それで、私は何をしなければなりませんか?