Background Color (optional - use if background color should be different from tint color):
multiSelect.selectedBackgroundColor = .blue
Shape:
multiSelect.borderWidth = 3 // Width of the dividers between segments and the border around the view.
multiSelect.borderRadius = 32 // Corner radius of the view.
Stack the segments vertically:
multiSelect.isVertical = true
Stack each segment contents vertically when it contains both image and text:
MultiSelectSegmentedControl
UISegmentedControl remake that supports selecting multiple segments, vertical stacking, combining text and images.
Features
Usage
Very similar to
UISegmentedControl
, can be used as a drop-in replacement in most cases.If you use Interface Builder, add a regular
UIView
and then set its class toMultiSelectSegmentedControl
.SwiftUI Usage
The properties mentioned below can be passed as arguments to the
MultiSegmentPicker
initializer, or used as view modifiers (e.g.,.borderWidth(3)
).Creating Segments
Each segment can contain an image, a text, or both:
Images are shown in full color (unlike
UISegmentedControl
). To make them render in the sametintColor
as the control, use template mode:Selecting Segments
Or just single selection:
Getting Selected Segments
Or to get the titles:
Handling User Selection Changes
You can use standard target-action:
Or conform to the delegate protocol:
… and set the delegate:
Changing Appearance
Color:
Background Color (optional - use if background color should be different from tint color):
Shape:
Stack the segments vertically:
Stack each segment contents vertically when it contains both image and text:
Text styling:
More label styling:
Installation
CocoaPods:
Swift Package Manager:
TODO
layoutMargins
,stackView.spacing
Meta
@yonatsharon
https://github.com/yonat/MultiSelectSegmentedControl