答案 0 :(得分:1)
UISegmentedControl有一个customization部分。
总结如下: 您所要做的就是为不同的状态组合提供分频器图像。这意味着您需要为以下状态提供3个图像:
代码如下:
<强>目标C 强>
// Image between two unselected segments.
[mySegmentedControl setDividerImage:image1 forLeftSegmentState:UIControlStateNormal
rightSegmentState:UIControlStateNormal barMetrics:barMetrics];
// Image between segment selected on the left and unselected on the right.
[mySegmentedControl setDividerImage:image1 forLeftSegmentState:UIControlStateSelected
rightSegmentState:UIControlStateNormal barMetrics:barMetrics];
// Image between segment selected on the right and unselected on the right.
[mySegmentedControl setDividerImage:image1 forLeftSegmentState:UIControlStateNormal
rightSegmentState:UIControlStateSelected barMetrics:barMetrics];
Swift
// Image between two unselected segments.
mySegmentedControl.setDividerImage(myImage, forLeftSegmentState: UIControlState.Normal,
rightSegmentState: UIControlState.Normal, barMetrics: UIBarMetrics.Default)
// Image between segment selected on the left and unselected on the right.
mySegmentedControl.setDividerImage(myImage, forLeftSegmentState: UIControlState.Selected,
rightSegmentState: UIControlState.Normal, barMetrics: UIBarMetrics.Default)
// Image between segment selected on the right and unselected on the left.
mySegmentedControl.setDividerImage(myImage, forLeftSegmentState: UIControlState.Normal,
rightSegmentState: UIControlState.Selected, barMetrics: UIBarMetrics.Default)
这是一个post,解释了如何实现这一目标。