Skip to content

Instantly share code, notes, and snippets.

@TAATHub
TAATHub / SegmentedControl.Swift
Created February 24, 2024 12:34
Custom Segmented Control with SwiftUI
protocol SegmentTypeProtocol: CaseIterable, Identifiable, Equatable {
var title: String { get }
var tintColor: Color? { get }
}
extension SegmentTypeProtocol {
var tintColor: Color? { nil }
}
struct SegmentedControl<SegmentType: SegmentTypeProtocol>: View where SegmentType.AllCases == [SegmentType] {