@property (weak, nonatomic) IBOutlet UISegmentedControl *Sgment; @end @implementation ArenaViewController - (void)viewDidLoad { [super viewDidLoad]; //设置控制器view的背景图片 self.view.layer.contents = (__bridge id)([UIImage imageNamed:@"NLArenaBackground"].CGImage); //设置segument普通状态下的的背景图片 [self.Sgment setBackgroundImage:[UIImage imageNamed:@"CPArenaSegmentBG"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; //设置segument选中状态下的的背景图片 [self.Sgment setBackgroundImage:[UIImage imageNamed:@"CPArenaSegmentSelectedBG"] forState:UIControlStateSelected barMetrics:UIBarMetricsDefault]; //设置segument的文字颜色 NSDictionary *attri = @{NSForegroundColorAttributeName : [UIColor whiteColor]}; //默认情况下 [self.Sgment setTitleTextAttributes:attri forState:UIControlStateNormal]; //选中情况下 [self.Sgment setTitleTextAttributes:attri forState:UIControlStateSelected]; }