SkillAgentSearch skills...

CustomSegmentedControl

Simple custom segmented control for UIKit (iOS)

Install / Use

/learn @dancarvajc/CustomSegmentedControl
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

CustomSegmentedControl

An simple example of a custom segmented control for UIKit.

<img src="assets/RocketSim_Screenshot_iPhone_14_Pro_2023-02-10_14.35.05.png" alt="RocketSim_Screenshot_iPhone_14_Pro_2023-02-10_14.35.05" width="200" /><img src="assets/RocketSim_Screenshot_iPhone_14_Pro_2023-02-10_14.36.08.png" alt="RocketSim_Screenshot_iPhone_14_Pro_2023-02-10_14.36.08" width="500" />

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

https://user-images.githubusercontent.com/71818002/218160590-67edcb86-1646-41f7-92a6-9f231f8f766f.mp4

Related Skills

View on GitHub
GitHub Stars4
CategoryDevelopment
Updated27d ago
Forks1

Languages

Swift

Security Score

75/100

Audited on Mar 7, 2026

No findings