您的位置:首页 > 移动开发 > IOS开发

iOS——类似QQsegment切换按钮

2017-03-28 00:00 295 查看
UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"洗车订单",@"其他订单", nil]];

segment.layer.masksToBounds = YES;

segment.layer.cornerRadius = 15;

segment.layer.borderColor = HKWHITE.CGColor;

segment.layer.borderWidth = 1.0;

//设置默认选择项索引

segment.selectedSegmentIndex = 0;

segment.frame = CGRectMake(0, 5, 180, 30);

segment.tintColor = HKWHITE;

//文字设置

NSMutableDictionary *attDic = [NSMutableDictionary dictionary];

attDic[NSFontAttributeName] = HKFont(15);

NSMutableDictionary *attDicSelected = [NSMutableDictionary dictionary];

attDicSelected[NSFontAttributeName] = HKFont(17);

[segment setTitleTextAttributes:attDic forState:UIControlStateNormal];

[segment setTitleTextAttributes:attDicSelected forState:UIControlStateSelected];

[segment addTarget:self action:@selector(selectSegment:) forControlEvents:UIControlEventValueChanged];

self.navigationItem.titleView = segment;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: