A replication of a segmented control in the iOS 13 Photos.app.
Demo.mp4
FloatingSwitchView.swift
FloatingSwitchView.xib
FloatingSwitchSegment.swift
FloatingSwitchSegment.xib
- Install a custom view on Interface Builder.
- Assign the custom view class as
FloatingSwitchView
. - Set an appropriate layouts. In the default implementation of FloatingSwitch, the width follows the intrinsic size.
- Set segments with
setSegments(with:)
method. - Set
target
andaction
. Then you can catch control events when users switch segments.
See SampleViewController.swift
for usage.
See LICENSE for details.