設置Segment

//設置邊框圓角

    segment.layer.cornerRadius = 10;

    segment.layer.masksToBounds = YES;

    segment.layer.borderWidth = 1;

    

    //設置選中背景顏色

    segment.segmentedControlStyle = UISegmentedControlStyleBar;

    segment.tintColor = [UIColor brownColor];

    //設置邊框顏色

    segment.layer.borderColor = [UIColor purpleColor].CGColor;

    [segment setBackgroundColor:[UIColor whiteColor]];

    

    //設置選中和未選中的字體顏色

    [segment setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor lightGrayColor]} forState:(UIControlStateNormal)];

    [segment setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor yellowColor]} forState:(UIControlStateSelected)];

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章