Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Text

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

What is the element/object ?

>Solution :

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)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading