-
Notifications
You must be signed in to change notification settings - Fork 176
Open
Description
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)")
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
