Skip to content

Latest commit

 

History

History
34 lines (22 loc) · 1.08 KB

README.md

File metadata and controls

34 lines (22 loc) · 1.08 KB

CustomSegmentedControl

An simple example of a custom segmented control for UIKit.

RocketSim_Screenshot_iPhone_14_Pro_2023-02-10_14.35.05RocketSim_Screenshot_iPhone_14_Pro_2023-02-10_14.36.08

Use

Declares the titles for each segment in an array.

private let buttonTitles: [String] = ["Button 1", "Button 2", "Button 3"]

Then create an instance of the custom segmented control passing it the array as argument:

private lazy var segmentedControl: CustomSegmetedControl = CustomSegmetedControl(buttonTitles: buttonTitles)

Finally, conforms to the delegate protocol to know which button was pressed.

extension ViewController: CustomSegmetedControlDelegate {
    func buttonPressed(buttonTitlesIndex: Int, title: String?) {
	// some action
    }
}

Video

segmentedControlDemo.mp4