Post

Replies

Boosts

Views

Activity

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
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
764
Sep ’20
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
883
Jul ’20
Remove the scroll in WebKit View
macOS, SwiftIs it possible to remove the scroll in WebKit View? (or make it not visible)I have a WebKit View from library and I have made the connection to the ViewController.swift:@IBOutlet weak var webView1: WKWebView!
Topic: UI Frameworks SubTopic: AppKit Tags:
6
0
6.8k
Jun ’20
Change a label on hover
(macOS, Swift, storyboards)Can I change a label on hover?WHAT I HAVE TRIED1- I have put a button in storyboard and make it transparent. It works if I click, but I could nof find how to if hover@IBOutlet weak var label1: NSTextField!@IBAction func button1(_ sender: NSButton) { label1.textColor = NSColor.gray}2- I have put a NSView and drag a NSClickGestureRecognizer to it. Again, it works on click but I cannot find a way to do it with hover@IBOutlet weak var label2: NSTextField!@IBAction func gestureRecognizer1(_ sender: NSClickGestureRecognizer) { label2.textColor = NSColor.gray}I could find something in Apple documentation. But it talks about UIButton. I cannot find a way to adapt to my case:https://developer.apple.com/documentation/uikit/uihovergesturerecognizer
Topic: UI Frameworks SubTopic: AppKit Tags:
6
0
3.4k
Dec ’19