FloatingSwitch icon indicating copy to clipboard operation
FloatingSwitch copied to clipboard

A replication of a segmented control in the iOS 13 Photos.app.

FloatingSwitch

A replication of a segmented control in the iOS 13 Photos.app.

Demo Image: Light Mode Demo Image: Dark Mode

Video

Core Classes

  • FloatingSwitchView.swift
  • FloatingSwitchView.xib
  • FloatingSwitchSegment.swift
  • FloatingSwitchSegment.xib

Usage

  1. Install a custom view on Interface Builder.
  2. Assign the custom view class as FloatingSwitchView.
  3. Set an appropriate layouts. In the default implementation of FloatingSwitch, the width follows the intrinsic size.
  4. Set segments with setSegments(with:) method.
  5. Set target and action. Then you can catch control events when users switch segments.

See SampleViewController.swift for usage.

License

See LICENSE for details.