Post

Replies

Boosts

Views

Activity

macOS Menu Bar
Xcode 16.2 Swift 6 macOS Sequoia 15.1 SwiftUI I am a beginner. If I understand we can add buttons to the default Menu Bar but not delete them. Am I right? If you do not need most of the buttons, how do you solve that? I can add a button: import SwiftUI @main struct NouMenuProvesApp: App { var body: some Scene { WindowGroup { ContentView() } .commands { CommandMenu("Custom") { Button("Custom Action") { print("Custom Action performed") } } } } } Can I delete a Menu Button or create a new simpler Menu Bar?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
1
0
361
Jan ’25
Make a link in macOS
How to make a link when I click to a button in macOS? This works well in iOS. How to do the same with macOS:     @IBAction func button1(_ sender: UIButton) {         if let url = URL(string: "some link") {             UIApplication.shared.open(url)         }     }
2
0
868
Aug ’22
Submit an macOS app and Xcode version
I have created a small app for macOS. I looked for information about how to submit it to the app store and read: "Build your apps using Xcode 13.1 or later…" https://developer.apple.com/macos/submit/ I have an old iMac Late 2013. Unfortunately, the last version I can install is Catalina 10.15.7, and the last Xcode I can install is version 12.4. Does it mean that I cannot publish my app? Is there any way I can submit it? Is buying a new mac the only solution? My iMac works well, and it is not easy for me to buy a new one. I would appreciate any recommendation Thank you
2
0
1.6k
Jul ’22
Window in all spaces
macOS, Swift, storyboards How can I make the window active in all spaces? I could find how to do that with storyboard: Select the window > Attributes > Spaces > Can join all spaces. How can I do the same with code (activate and de-activate)
1
0
1k
May ’22
Do something at a specific time
I want my program to do something at a specific time. This is what I have tried: func rellotge() { countdownRellotge = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(actualitzaRellotge), userInfo: nil, repeats: true) } @objc func actualitzaRellotge() { let date = Date() let calendar = Calendar.current hour = calendar.component(.hour, from: date) minutes = calendar.component(.minute, from: date) seconds = calendar.component(.second, from: date) //print (minutes, ":", seconds) if (minutes == 40 && seconds == 0){ print ("do something") } } This does not work if the computer goes to sleep. Even before that, it becomes buggy. (When I print the seconds, it seems that sometimes it skips some seconds) How can I reliably make my program do something at a specific minute-second?
1
0
626
Apr ’22
NSView not transparent in a transparent window
(Swift, macOS, storyboards.) I have a window that is semitransparent and a NSView that I want to be not transparent or with a different transparent degree. With my code, if I make the window transparent the NSView is also transparent. func finestra() { self.view.window?.alphaValue = 0.7 } func nsView1() { nsViewOutlet.wantsLayer = true nsViewOutlet.layer?.backgroundColor = NSColor.white.cgColor nsViewOutlet.alphaValue = 1 }
0
0
642
Mar ’22
Day of the week. From String to int
Is it possible to convert a var with the day of the week to a number? (and the other way around) let diaSetmana = "Monday" let diaSetmana2 = 2 I know how to convert from date(): let date = Date() let calendar = Calendar.current let dateFormatter = DateFormatter() dateFormatter.dateFormat = "EEEE" let dayString = dateFormatter.string(from: date) I am asking for converting not from date() but from a var that I have a random day of the week
1
0
850
Mar ’22
Scroll View with text and img inside
(Swift, macOS, storyboards) I try to make a simple page with an scroll, text and images. Similar to help pages in all mac programs. For instance, TextEdit help: I tried many things. For instance: Scroll View with constraints 0 to top, bottom, leading, trailing Inside the Scroll View: a Label, an Image View, another Label. The labels with constraints 20px top, bottom, leading, trailing. Labels Priority 750. The rest of constraints Priority 1000 With this, the user can change the width and height of the window, the text adapts but if the window is smaller than the content, I do not see the scroll. The attributes of the scroll are Show Vertical Scroller and Automatically Hide Scroller. If I change one of the options, I do not see the scroll space (or I see the scroll but not the movable part of the scroll) How to have text, images, a window that can change width, height, and a scroll that appears when the content is bigger than the window. (Like a regular web page or the help that Apple has in many programs)?
5
0
2.2k
Oct ’21
Open a View from the menu
(Swift, macOS, storyboards) How to open a view (not a window) by clicking a menu item? Let's suppose I have one window and two views: I try to open with Menu item: "open view 1" and item: "open view 2": (Here I asked the same question. Claude 31 solved very well with a button in one of the views. Here I am asking the same but with a button in the menu or menu item: https://developer.apple.com/forums/thread/690644 ) (Be aware that I am a beginner and I try to learn. Please explain in a simple way if possible)
2
0
1.9k
Sep ’21
How to open a view
(Swift, macOS, Storyboards) How to open a View with code and macOS? (a View, not a Window) I can open a Window Controller: var controller: NSWindowController? if controller == nil { let storyboard:NSStoryboard = NSStoryboard(name: "Main", bundle: nil) controller = storyboard.instantiateController(withIdentifier: "window1") as? NSWindowController } controller?.showWindow(self) But I could not figure out how to open a View Controller. What would the be equivalent code for a View Controller in macOS?
6
0
1.4k
Sep ’21
macOS Menu Bar
Xcode 16.2 Swift 6 macOS Sequoia 15.1 SwiftUI I am a beginner. If I understand we can add buttons to the default Menu Bar but not delete them. Am I right? If you do not need most of the buttons, how do you solve that? I can add a button: import SwiftUI @main struct NouMenuProvesApp: App { var body: some Scene { WindowGroup { ContentView() } .commands { CommandMenu("Custom") { Button("Custom Action") { print("Custom Action performed") } } } } } Can I delete a Menu Button or create a new simpler Menu Bar?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
1
Boosts
0
Views
361
Activity
Jan ’25
Make a link in macOS
How to make a link when I click to a button in macOS? This works well in iOS. How to do the same with macOS:     @IBAction func button1(_ sender: UIButton) {         if let url = URL(string: "some link") {             UIApplication.shared.open(url)         }     }
Replies
2
Boosts
0
Views
868
Activity
Aug ’22
Submit an macOS app and Xcode version
I have created a small app for macOS. I looked for information about how to submit it to the app store and read: "Build your apps using Xcode 13.1 or later…" https://developer.apple.com/macos/submit/ I have an old iMac Late 2013. Unfortunately, the last version I can install is Catalina 10.15.7, and the last Xcode I can install is version 12.4. Does it mean that I cannot publish my app? Is there any way I can submit it? Is buying a new mac the only solution? My iMac works well, and it is not easy for me to buy a new one. I would appreciate any recommendation Thank you
Replies
2
Boosts
0
Views
1.6k
Activity
Jul ’22
Window in all spaces
macOS, Swift, storyboards How can I make the window active in all spaces? I could find how to do that with storyboard: Select the window > Attributes > Spaces > Can join all spaces. How can I do the same with code (activate and de-activate)
Replies
1
Boosts
0
Views
1k
Activity
May ’22
Do something at a specific time
I want my program to do something at a specific time. This is what I have tried: func rellotge() { countdownRellotge = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(actualitzaRellotge), userInfo: nil, repeats: true) } @objc func actualitzaRellotge() { let date = Date() let calendar = Calendar.current hour = calendar.component(.hour, from: date) minutes = calendar.component(.minute, from: date) seconds = calendar.component(.second, from: date) //print (minutes, ":", seconds) if (minutes == 40 && seconds == 0){ print ("do something") } } This does not work if the computer goes to sleep. Even before that, it becomes buggy. (When I print the seconds, it seems that sometimes it skips some seconds) How can I reliably make my program do something at a specific minute-second?
Replies
1
Boosts
0
Views
626
Activity
Apr ’22
NSView not transparent in a transparent window
(Swift, macOS, storyboards.) I have a window that is semitransparent and a NSView that I want to be not transparent or with a different transparent degree. With my code, if I make the window transparent the NSView is also transparent. func finestra() { self.view.window?.alphaValue = 0.7 } func nsView1() { nsViewOutlet.wantsLayer = true nsViewOutlet.layer?.backgroundColor = NSColor.white.cgColor nsViewOutlet.alphaValue = 1 }
Replies
0
Boosts
0
Views
642
Activity
Mar ’22
Buttons in the title bar
(macOS, Swift, storyboard) Is it possible to have buttons in the title bar? I would like the same buttons that Apple uses in the preferences
Replies
1
Boosts
0
Views
2.0k
Activity
Mar ’22
Day of the week. From String to int
Is it possible to convert a var with the day of the week to a number? (and the other way around) let diaSetmana = "Monday" let diaSetmana2 = 2 I know how to convert from date(): let date = Date() let calendar = Calendar.current let dateFormatter = DateFormatter() dateFormatter.dateFormat = "EEEE" let dayString = dateFormatter.string(from: date) I am asking for converting not from date() but from a var that I have a random day of the week
Replies
1
Boosts
0
Views
850
Activity
Mar ’22
Scroll View with text and img inside
(Swift, macOS, storyboards) I try to make a simple page with an scroll, text and images. Similar to help pages in all mac programs. For instance, TextEdit help: I tried many things. For instance: Scroll View with constraints 0 to top, bottom, leading, trailing Inside the Scroll View: a Label, an Image View, another Label. The labels with constraints 20px top, bottom, leading, trailing. Labels Priority 750. The rest of constraints Priority 1000 With this, the user can change the width and height of the window, the text adapts but if the window is smaller than the content, I do not see the scroll. The attributes of the scroll are Show Vertical Scroller and Automatically Hide Scroller. If I change one of the options, I do not see the scroll space (or I see the scroll but not the movable part of the scroll) How to have text, images, a window that can change width, height, and a scroll that appears when the content is bigger than the window. (Like a regular web page or the help that Apple has in many programs)?
Replies
5
Boosts
0
Views
2.2k
Activity
Oct ’21
Open a View from the menu
(Swift, macOS, storyboards) How to open a view (not a window) by clicking a menu item? Let's suppose I have one window and two views: I try to open with Menu item: "open view 1" and item: "open view 2": (Here I asked the same question. Claude 31 solved very well with a button in one of the views. Here I am asking the same but with a button in the menu or menu item: https://developer.apple.com/forums/thread/690644 ) (Be aware that I am a beginner and I try to learn. Please explain in a simple way if possible)
Replies
2
Boosts
0
Views
1.9k
Activity
Sep ’21
How to open a view
(Swift, macOS, Storyboards) How to open a View with code and macOS? (a View, not a Window) I can open a Window Controller: var controller: NSWindowController? if controller == nil { let storyboard:NSStoryboard = NSStoryboard(name: "Main", bundle: nil) controller = storyboard.instantiateController(withIdentifier: "window1") as? NSWindowController } controller?.showWindow(self) But I could not figure out how to open a View Controller. What would the be equivalent code for a View Controller in macOS?
Replies
6
Boosts
0
Views
1.4k
Activity
Sep ’21