PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, November 7, 2022

[FIXED] How to prevent Picker to fold into a submenu in SwiftUI macOS

 November 07, 2022     macos, menu, picker, swiftui     No comments   

Issue

I'm trying to combine Picker and some buttons inside Menu in macOS SwiftUI app. Unfortunately Picker is folding into submenu automatically and I'm struggle to find a solution. How to prevent Picker to fold, or maybe there is a better solution around?

Menu("Budgets") {
    Picker("Budgets", selection: $account) {
        Button("Personal") {}.tag(1)
        Button("Business") {}.tag(2)
    }.labelsHidden()
                
    Divider()
                
    Button("New Budget…") {}
    Button("Manage Budgets…") {}
}

Preview


Solution

You need inline picker style, like

 Picker("Budgets", selection: $account) {
      Button("Personal") {}.tag(1)
      Button("Business") {}.tag(2)
 }
 .labelsHidden()
 .pickerStyle(.inline)    // << here !!

enter image description here



Answered By - Asperi
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing