Swift package · v0.1.2

KLGlassSegments

Use navigation-style segmented controls across native glass and material fallback paths.

SwiftUI and UIKit segmented controls with generic selection identity, reselect callbacks, drag cancellation, accessibility identifiers, and Reduce Motion handling. Native glass is used where iOS provides it.

Platforms
iOS 17+ · macOS 14+
Toolchain
Swift 6.0+
License
MIT
Dependencies
None

Functions

  • Binding-driven SwiftUI and UIControl-based UIKit APIs
  • Stable selection across refreshed generic segment IDs
  • Reselect, drag cancellation, and VoiceOver activation
  • Native iOS glass with a material fallback

Not included

It renders and manages segmented-control interaction. Navigation state, haptics policy, application content, and product-specific styling remain with the integrating application.

Install with SwiftPM

Package.swiftSwift
.package(url: "https://github.com/KoenLee1023/KLGlassSegments.git", from: "0.1.2")

Usage

Integration exampleSwift
KLGlassSegmentedControl(
    segments: segments,
    selection: $selection,
    floatingAction: composeAction
    )
KLGlassSegmentedControl

The SwiftUI control binds a selected ID and accepts segments, style, metrics, an optional action, and an optional reselect callback.

KLGlassSegmentedUIKitControl

The UIKit control accepts refreshed segments, applies external selection, and dispatches .valueChanged for committed changes.

KLGlassSegment

Describes one generic-ID item with title, SF Symbols, optional selected tint, accessibility identifier, and UIKit images where available.

Demo apps

GlassNavigation

Demonstrates selection, reselect, a floating action, and the fallback presentation.

SegmentGallery

Shows style, metrics, Reduce Motion, and accessibility-oriented control variations.