iOS UISegmentedControl改变样式

来源:互联网 发布:xp禁止程序联网软件 编辑:程序博客网 时间:2024/06/05 17:54
NSArray *titleArray = @[@"商品列表",@"企业列表",@"个人中心"];UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:titleArray];segment.frame = CGRectMake(12, 45, WIDTH-24, 25);segment.tintColor = [UIColor whiteColor];NSDictionary* selectedTextAttributes = @{NSFontAttributeName:[UIFont boldSystemFontOfSize:12],NSForegroundColorAttributeName: COLOR};[segment setTitleTextAttributes:selectedTextAttributes forState:UIControlStateSelected];NSDictionary* unselectedTextAttributes = @{NSFontAttributeName:[UIFont boldSystemFontOfSize:12],NSForegroundColorAttributeName: [UIColor whiteColor]};[segment setTitleTextAttributes:unselectedTextAttributes forState:UIControlStateNormal];segment.selectedSegmentIndex = 1;//默认选中[backGroundView addSubview:segment];
1 0
原创粉丝点击