2017-09-05 106 views
0

早上好,变酥料饼HIGHT和取消隐藏的一个新领域

我有(适用于MacOS迅速4)这个豆蔻例如:

故事板

enter image description here

结果

enter image description here

在我的popover中有三个按钮。 我在灰色按钮上有一个IBAction。

现在我想实现下面的情况,如果我按的灰色按钮:

enter image description here

  • 我想改变我的酥料饼的高度
  • 的文本框下方的灰色按钮应该隐藏。
  • 两个白色的按钮应该动起来

改变我酥料饼的我的成功尝试这样的高度:

@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) 

} 

我知道,我可以隐藏这样的文本字段:mytextfield.isHidden = true但是我怎样才能在同一个位置上移动两个白色按钮,在那里显示文本框?

回答

0

设置textField所在按钮的位置。

@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 
} 
+0

感谢您的解决方案。同时我找到了另一种方式来做到这一点。在我的故事板中,我设置了白色和灰色按钮之间的垂直间距,通过IBOutlet连接此约束并将约束值设置为10(而不是默认值100)。非常感谢 :) – Ghost108