OS X Cocoa Auto Layout hidden elements

后端 未结 8 1732
被撕碎了的回忆
被撕碎了的回忆 2021-01-31 17:06

I am trying to use the new Auto Layout in Lion because it seems quite nice. But I can not find good information about how to do things. For example:

I have two labels:

8条回答
  •  情话喂你
    2021-01-31 17:50

    Solved this issue programmatically. I have a few buttons in a row, and I may decide to hide one at any time.

    Used Cartography to replace them each time hidden changes in any of them.

    let buttons = self.buttons!.filter { button in
        return !button.hidden
    }
    
    constrain(buttons, replace: self.constraintGroup) { buttons in
        let superview = buttons.first!.superview!
    
        buttons.first!.left == superview.left
    
        for var i = 1; i < buttons.count; i++ {
            buttons[i].left == buttons[i-1].right + 10
        }
    
        buttons.last!.right == superview.right
    }
    

提交回复
热议问题