Swiftpack.co - Package - darioGzlez/FloatingSegmentedControl
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.

SwiftUI reusable implementation of the iOS 13 photos app picker.

PRs Welcome

:sparkles: Features

  • ☑ Auto resizable view based on the number of items and the size of them.
  • OnSelectedItem method to execute logic for item selection.

:open_book: Next features

  • ☐ Ability to customize the color of the bar, items and selector.
  • ☐ Customization of disable the drop shadow of the view.

:gear: Requirements

  • iOS 13+
  • Xcode 11+


Using Xcode's Swift Package Manager, it can be installed by going to File -> Swift Packages -> Add Package Dependency and pasting the URL of this repository.

dependencies: [
  .package(url: "https://github.com/darioGzlez/FloatingSegmentedControl.git", from: "1.0.0")


The floating segmented control takes two parameters: a string array of the elements to display and a callback function that's given the selected element index.

public init(_ items: [String], title: String, onSelected: @escaping (Int) -> ()) {
      self.items = items
      self.title = title
      self.onSelected = onSelected

Demo app

Simple app that uses the Floating Segmented Control to switch beetween satellite and standard modes for a MapView.

import FloatingSegmentedControl

struct ContentView: View {
    @State var items = ["Satellite", "Standad"]
    @State var mapType: MKMapType = .hybrid
    var body: some View {
        ZStack {
            Map(mapType: $mapType).edgesIgnoringSafeArea(.top)
            VStack {
                  title: "Map view",
                  onSelected: onSelected)
    func onSelected(index: Int) {
        switch index {
        case 0:
            mapType = .hybrid
        case 1:
            mapType = .standard
            mapType = .hybrid


FloatingSegmentedControl is under the MIT license. See the LICENSE file for more info.


Stars: 68


- 2021-01-05T15:12:20