Post

Replies

Boosts

Views

Activity

Usable screen space in a Mac
(Swift, macOS, storyboards) I can find the total height of the screen: let totalHight = NSScreen.main?.frame.height To know the real space I have to subtract 23 px for the Menu Bar. let usableHight = totalHight - 23 But on some occasions the user may not have the Menu Bar active (System Preferences > General > uncheck Automatically hide and show the menu bar) Is there a way to know if the Menu Bar is hidden or show? or perhaps there is another way to know the real usable height of the screen?
3
0
983
Aug ’21
Animate sizeToFit
I change the text of a label dynamically (so I do not know the text of the label) how can I animate the size to fit. I am looking for a smooth, elegant transition for design purposes. What I have tried:         NSAnimationContext.runAnimationGroup({ (context) in             context.duration = 4.0 label1.stringValue = "long, long text"             label1.animator().sizeToFit()         })
5
0
1.6k
Aug ’21
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
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