Skip to content

Issues with Autolayout and sliderBackgroundColor #16

Description

@ajaybeniwal

screen shot 2017-02-25 at 6 58 39 pm

I am trying to add TwicketSegment Control to my controller but Im facing issues adding to the view with autolayout , it shows and white background strip and the rounded corners come out of the constraints as well

Also setting slider sliderBackgroundColor does not change color for me

import UIKit
import TwicketSegmentedControl
import SnapKit
class PendingActionViewController: UIViewController,TwicketSegmentedControlDelegate {
    var segmentControlView:UIView = {
        var uiView = UIView()
        uiView.backgroundColor =  UIColor.init(red: 0/255.0, green: 102/255.0, blue: 204/255.0, alpha: 1.0)
        return uiView
    }()
    
    var contentView:UIView = {
        var uiView = UIView()
        
        return uiView
        
    }()
    
    var twicketSegmentControl:TwicketSegmentedControl = {
        var twicketSegmentControl : TwicketSegmentedControl = TwicketSegmentedControl(frame:CGRect.zero)
        let titles = ["Messages(4)", "Orders(0)", "Shipments(1)"]
        twicketSegmentControl.setSegmentItems(titles)
        twicketSegmentControl.highlightTextColor = UIColor.white
        twicketSegmentControl.defaultTextColor = UIColor.white
        twicketSegmentControl.sliderBackgroundColor = UIColor.init(red: 26/255.0, green: 153/255.0, blue: 255/255.0, alpha: 1.0)
        twicketSegmentControl.segmentsBackgroundColor = UIColor.red
        return twicketSegmentControl
    }()
    override func viewDidLoad() {
        self.title = "Pending Items"
        super.viewDidLoad()
        configureViewHierarchy()
    }
    
    func configureViewHierarchy(){
        view.addSubview(segmentControlView)
        segmentControlView.snp.makeConstraints { (make) in
            make.top.left.right.equalTo(view)
        }
        
        segmentControlView.addSubview(twicketSegmentControl)
        twicketSegmentControl.delegate = self;
        twicketSegmentControl.snp.makeConstraints { (make) in
            make.top.equalTo(segmentControlView).offset(10)
            make.left.equalTo(segmentControlView).offset(16)
            make.right.equalTo(segmentControlView).offset(-16)
            make.bottom.equalTo(segmentControlView).offset(-10)
            make.height.equalTo(40)
        }
        
        view.addSubview(contentView)
        contentView.snp.makeConstraints { (make) in
            make.left.right.equalTo(view)
            make.bottom.equalTo(view)
            make.top.equalTo(segmentControlView.snp.bottom)
        }

    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    func didSelect(_ segmentIndex: Int) {
        print("Selected index: \(segmentIndex)")
    }
    

}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions