设置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)];

你可能感兴趣的:(设置Segment)