Post

Replies

Boosts

Views

Activity

How to stop an animation
(swift, storyboards, macOS) Can I stop or pause an animation? (I could find how to remove it: view1.layer?.removeAllAnimations() Here is the official documentation but I do not understand: https://developer.apple.com/documentation/uikit/uiviewanimating/1649843-pauseanimation)     @IBAction func fadeOut(_ sender: NSButton) {         NSAnimationContext.runAnimationGroup({ (context) in             context.duration = 5.0             view1.animator().alphaValue = 0         })     }
3
0
2.1k
Aug ’21
Animate a macOS window
(swift, macOS, storyboards) I can animate a window just adding animate: true to a regular way to control a window. Is there any way to control the animation, especially the time the animation will take? self.view.window?.setFrame(NSRect(x:0, y:0, width:300, height:300), display: true, animate: true)
2
0
1.1k
Aug ’21
Presentation single with code
(swift, macOS, storyboards) I open a window with code. Every time the user clicks the button the same window opens again and again. How to avoid that? This opens well the window, but multiple times:     @IBAction func obrirAmbCodi(_ sender: NSButton) {         let storyboard:NSStoryboard = NSStoryboard(name: "Main", bundle: nil)         guard let controller:NSWindowController = storyboard.instantiateController(withIdentifier: "finestra3") as? NSWindowController else { return }             controller.showWindow(self)     } If I open the window with a segue (storyboard control drag) I can accomplish that by selecting the window controller > Attributes > Presentation > Single. But it seems that it does not work if I open the window with code
2
0
698
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