When you want a fully UISegmentedControl or UISwitch you can use SHSegmentedControl which is written in Swift.
Uou can customize as much as you can
Colors, fonts, radius and all things can be set
Use text or icons as segments, or add your own custom segments
Right-to-left languages support
SHSegmentedControl is available through Swift Package Manager. To install
it, simply go to Xcode under File > Swift Packages > Add Package Dependency...
If you prefer not to use SPM or CocoaPods, you can integrate SHSegmentedControl into your project manually.
let control = SHSegmentedControl(
frame: CGRect(x: 0, y: 0, width: 350, height: 50),
segments: LabelSegment.segments(withTitles: ["Segment1", "Segment2", "Segment3"],
normalFont: UIFont(name: "HelveticaNeue-Light", size: 14.0)!,
normalTextColor: .red,
selectedFont: UIFont(name: "HelveticaNeue-Bold", size: 14.0)!,
selectedTextColor: .green),
index: 1,
options: [.backgroundColor(.white),
.indicatorViewBackgroundColor(.blue)])
control.addTarget(self, action: #selector(ViewController.controlValueChanged(_:)), for: .valueChanged)
view.addSubview(control)
Feel free to submit Pull Requests or send me your feedback and suggestions!
Shayan Mehranpoor
SHSegmentedControl is available under the MIT license. See the LICENSE file for more info.
link |
Stars: 19 |
Last commit: 4 years ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics