2017-02-08 12 views
0

Как я могу достичь этого стиля с помощью HMSegmentedControl при выборе индекса. Пожалуйста, помогите мне, как я могу достичь этого в swift 3.0 ...... если это возможноКак установить цвет фона выбранного сегмента с помощью HMSegmentedControl в Swift 3.0

HMSegmentedControl

Вот мой код:

func setupSegementCategory(){ 
     segmentCategory.sectionTitles = ["home","about","contract","home","about","contract"] 
     segmentCategory.backgroundColor = #colorLiteral(red: 0.7683569193, green: 0.930, blue: 0.9995251894, alpha: 1) 
     segmentCategory.translatesAutoresizingMaskIntoConstraints = false 
     segmentCategory.selectionIndicatorLocation=HMSegmentedControlSelectionIndicatorLocation.down 
     segmentCategory.isVerticalDividerEnabled=false 
     segmentCategory.selectedSegmentIndex=0 
     segmentCategory.selectionIndicatorColor = UIColor.white 
     segmentCategory.segmentWidthStyle = HMSegmentedControlSegmentWidthStyle.dynamic 
     segmentCategory.titleTextAttributes = [ 
      NSForegroundColorAttributeName : #colorLiteral(red: 0.2549019754, green: 0.2745098174, blue: 0.3019607961, alpha: 1), 
      NSFontAttributeName : UIFont.systemFont(ofSize: 17) 
     ] 
     segmentCategory.backgroundColor=Constant.GlobalConstants.kColor_blue 
     segmentCategory.selectedTitleTextAttributes = [ 
      NSFontAttributeName : UIFont.systemFont(ofSize: 17), 
      NSForegroundColorAttributeName :UIColor(red:0.74, green:0.70, blue:1.00, alpha:1.0) 
     ] 

     segmentCategory.addTarget(self, action:#selector(segmentedControlValueChanged(sender:)), for: .valueChanged) 


    } 
    func segmentedControlValueChanged(sender: UISegmentedControl) { 
     let sortedViews = sender.subviews.sorted(by: { $0.frame.origin.x < $1.frame.origin.x }) 

     for (index, view) in sortedViews.enumerated() { 
      if index == sender.selectedSegmentIndex { 
       view.tintColor = UIColor.red 
      } else { 
       view.tintColor = UIColor.lightGray 
      } 
     } 
    } 

ответ

0

Там в настоящее время нет способа, чтобы получить этот стиль в HMSegmentedControl.

 Смежные вопросы

  • Нет связанных вопросов^_^