UISegmentedControl的简单使用
UISegmentedControl *seg = (UISegmentedControl *)self.navigationItem.titleView;
[seg setBackgroundImage:[UIImage imageNamed:@"name_no"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[seg setBackgroundImage:[UIImage imageNamed:@"name_sel"] forState:UIControlStateSelected barMetrics:UIBarMetricsDefault];
[seg setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]} forState:UIControlStateNormal];
[seg setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]} forState:UIControlStateSelected];
[seg setTintColor:[UIColor clearColor]];
barMetrics枚举
UIBarMetricsDefault
UIBarMetricsCompact
UIBarMetricsDefaultPrompt
UIBarMetricsCompactPrompt
|