//設置邊框圓角
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)];