Good morning,
I have this litte example (swift 4 for macOS):
Storyboard
Result
In my popover are three buttons. I have an IBAction on the grey button.
Now I would like to realize the following situation, if I press the grey button:
To change the height of my popover I tried this with success:
@IBAction func buttonPressed(_ sender: NSButton) {
self.view.window?.animator().setFrame(
NSRect(origin: CGPoint(x: self.view.window!.frame.origin.x, y: self.view.window!.frame.origin.y), size: CGSize(width: self.view.window!.frame.width, height: self.view.window!.frame.height - 100)), display: true, animate: true)
}
I know, that I can hide the text fields like this: mytextfield.isHidden = true
but how can i move up the two white buttons on the same position, where the textfields were shown before?
Set the position of the buttons at where textField is.
@IBAction func buttonPressed(_ sender: NSButton) {
textField.isHidden = true
textField2.isHidden = true
buttonA.frame.origin.y = (textField.frame.origin.y + textField2.frame.origin.y)/2
buttonB.frame.origin.y = (textField.frame.origin.y + textField2.frame.origin.y)/2
}