Trying to identify an element on Apple Guideline website for use with Swift

52 Views Asked by At

I was accessing one of the Apple websites about Pickers. The site below:

https://developer.apple.com/design/human-interface-guidelines/components/selection-and-input/pickers/

I was interessed to use the Picker below, but I can't identify what type of element is that.

Text

It appears to be an element to choose between two options("daily Notification Avg" or "A to Z").

What is the element/object ?

1

There are 1 best solutions below

1
Shehata Gamal On BEST ANSWER

SwiftUI

You can use a picker with segmented style

struct ContentView: View {
    @State private var selected = 0

    var body: some View {
        VStack {
            Picker("", selection: $selected) {
                Text("Daily Notification Avg").tag(0)
                Text("A to Z").tag(1) 
            }
            .pickerStyle(.segmented)
        }
    }
}

UIKit

segmentedControl = UISegmentedControl (items: ["Daily Notification Avg","A to Z"]) 
segmentedControl.frame = CGRectMake(60, 250,200, 30) 
segmentedControl.selectedSegmentIndex = 0 
segmentedControl.addTarget(self, action: #selector(segmentedControlAction(_)), forControlEvents: .ValueChanged) 
view.addSubview(segmentedControl)