在Swift中更改分段控件背景图像

时间:2015-11-20 11:07:49

标签: image swift background uisegmentedcontrol

我想将图像用作我的分段控件的背景。

哪种方式最好?

2 个答案:

答案 0 :(得分:0)

我在发布问题时找到了方法。如果有人需要,我会与你分享。

segmentedControlName.backgroundColor = UIColor(patternImage: UIImage(named: "imageName")!)

答案 1 :(得分:0)

 for subview in (sender.subviews as! [UIView]) {
   if (subview.isSelected) {
     subview.backgroundbackgroundColor = UIColor.redColor()
   } else {
     subview.backgroundColor = nil
   } 
 }
相关问题