//个性推荐 歌单 主播电台 排行榜 NSArray* promoteArray=@[@"个性推荐",@"歌单",@"主播电台",@"排行榜"]; UISegmentedControl* promoteSgement=[[UISegmentedControl alloc]initWithItems:promoteArray]; promoteSgement.frame=CGRectMake(0, 64, screenWidth, 40); [promoteSgement setSelectedSegmentIndex:0];//默认选择第一个 promoteSgement.tintColor = [UIColor clearColor];//去掉颜色 现在整个segment都看不见 NSDictionary* selectedTextAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:15],NSForegroundColorAttributeName:[UIColor colorWithRed:212/256.0 green:21/256.0 blue:10/256.0 alpha:1]}; [promoteSgement setTitleTextAttributes:selectedTextAttributes forState:UIControlStateSelected];//设置选择时文字的属性 NSDictionary* unselectedTextAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:15],NSForegroundColorAttributeName: [UIColor blackColor]}; [promoteSgement setTitleTextAttributes:unselectedTextAttributes forState:UIControlStateNormal];//设置未选择时文字的属性 [self.view addSubview:promoteSgement];