Post

Replies

Boosts

Views

Activity

Reply to Animate sizeToFit
I want to animate (using any method) the change of the label's text in a macOS app. With the code I provide, the change occurs when I click the button. I see no animation and no delay. import Cocoa class ViewController: NSViewController {     @IBOutlet weak var label1: NSTextField!     override func viewDidLoad() {         super.viewDidLoad()     }     @IBAction func button2(_ sender: NSButton) {         NSAnimationContext.runAnimationGroup({ (context) in             context.duration = 4.0             label1.stringValue = "long, long text"             label1.animator().sizeToFit()         })     } }
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21
Reply to How to open a view
These are some of the things I tried: var controller: NSWindowController? @IBAction func loadSecondFromMenu(_ sender: NSButton) { let storyboard: NSStoryboard = NSStoryboard(name: "Main", bundle: nil) let myViewController = storyboard.instantiateController(withIdentifier: "SecondView") as? SecondViewController //self.view.window?.contentViewController = myViewController //error: Value of type 'AppDelegate' has no member 'view'         //controller?.contentViewController = myViewController //no error, and it does not open any window }
Topic: Programming Languages SubTopic: Swift Tags:
Sep ’21
Reply to How to open a view
I have opened a new thread. I have been searching and trying things but still, I do not understand your sketch solution. Are you sure this is macOS and storyboards? It looks very new to me and I do not know how to learn.
Topic: Programming Languages SubTopic: Swift Tags:
Sep ’21
Reply to Animate sizeToFit
I want to animate (using any method) the change of the label's text in a macOS app. With the code I provide, the change occurs when I click the button. I see no animation and no delay. import Cocoa class ViewController: NSViewController {     @IBOutlet weak var label1: NSTextField!     override func viewDidLoad() {         super.viewDidLoad()     }     @IBAction func button2(_ sender: NSButton) {         NSAnimationContext.runAnimationGroup({ (context) in             context.duration = 4.0             label1.stringValue = "long, long text"             label1.animator().sizeToFit()         })     } }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to Animate a macOS window
That is just fantastic! I have been hours searching and trying things and you solved in a minute!. Thank you!
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to How to open a view
I have a window controller and two views. With my code, I open view1. I try to open view2 with code. I do not understand your code. It gives me error.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to How to open a view
These are some of the things I tried: var controller: NSWindowController? @IBAction func loadSecondFromMenu(_ sender: NSButton) { let storyboard: NSStoryboard = NSStoryboard(name: "Main", bundle: nil) let myViewController = storyboard.instantiateController(withIdentifier: "SecondView") as? SecondViewController //self.view.window?.contentViewController = myViewController //error: Value of type 'AppDelegate' has no member 'view'         //controller?.contentViewController = myViewController //no error, and it does not open any window }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to How to open a view
I have opened a new thread. I have been searching and trying things but still, I do not understand your sketch solution. Are you sure this is macOS and storyboards? It looks very new to me and I do not know how to learn.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to Scroll View with text and img inside
When you say "5. you can keep the content layout and frame layout ON", what do you mean?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Scroll View with text and img inside
Here is an example with macOS:
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Scroll View with text and img inside
Open Library > Container View. If you use that, it creates that View Controller. In any case, I tried both ways with the same result.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Oct ’21