Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- override func viewDidLoad() {
- super.viewDidLoad()
- // Note: you may need to set the layout contraints for it by yourself
- // to make it displayed correctly.
- let segmentedControl = MaterialSegmentedControl(frame: CGRect(x: 0.0, y: 0.0, width: 200.0, height: 30.0))
- // Configure the view, note that you need to call updateViews in order to apply your cofiguration.
- segmentedControl.selectorColor = .black
- segmentedControl.selectorTextColor = .black
- setSampleSegments(segmentedControl, 18.0)
- segmentedControl.updateViews()
- self.view.addSubview(segmentedControl)
- segmentedControl.translatesAutoresizingMaskIntoConstraints = false
- }
- /**
- Create sample segments for the segmented control.
- - Parameter segmentedControl: The segmented control to put these segments into.
- - Parameter cornerRadius: The corner radius to be set to segments and selectors.
- */
- private func setSampleSegments(_ segmentedControl: MaterialSegmentedControl, _ cornerRadius: CGFloat) {
- for i in 0..<3 {
- // Button background needs to be clear, it will be set to clear in segmented control anyway.
- let button = MaterialButton(text: "Segment \(i)", textColor: .gray, bgColor: .clear, cornerRadius: cornerRadius)
- segmentedControl.segments.append(button)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement