iOS——相似QQsegment切換按鈕

UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"洗車訂單",@"其餘訂單", nil]];orm

    segment.layer.masksToBounds = YES;索引

    segment.layer.cornerRadius = 15;get

    segment.layer.borderColor = HKWHITE.CGColor;it

    segment.layer.borderWidth = 1.0;io

    //設置默認選擇項索引table

    segment.selectedSegmentIndex = 0;select

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

    segment.tintColor = HKWHITE;tab

    

    //文字設置di

    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;

相關文章
相關標籤/搜索