我正在快速使用 CosmicMind 的 Material 库。我正在尝试让该Menu
示例与程序化自动布局一起使用 - 我在哪里可以找到如何使其工作的示例?
从Github上的示例中,我还没有找到使用自动布局的方法。
/// Prepares the FlatMenu example.
private func prepareFlatbMenuExample() {
let btn1: FlatButton = FlatButton()
btn1.addTarget(self, action: "handleFlatMenu", forControlEvents: .TouchUpInside)
btn1.setTitleColor(MaterialColor.white, forState: .Normal)
btn1.backgroundColor = MaterialColor.blue.accent3
btn1.pulseColor = MaterialColor.white
btn1.setTitle("Sweet", forState: .Normal)
view.addSubview(btn1)
let btn2: FlatButton = FlatButton()
btn2.setTitleColor(MaterialColor.blue.accent3, forState: .Normal)
btn2.borderColor = MaterialColor.blue.accent3
btn2.pulseColor = MaterialColor.blue.accent3
btn2.borderWidth = .Border1
btn2.setTitle("Good", forState: .Normal)
view.addSubview(btn2)
let btn3: FlatButton = FlatButton()
btn3.setTitleColor(MaterialColor.blue.accent3, forState: .Normal)
btn3.borderColor = MaterialColor.blue.accent3
btn3.pulseColor = MaterialColor.blue.accent3
btn3.borderWidth = .Border1
btn3.setTitle("Nice", forState: .Normal)
view.addSubview(btn3)
// Initialize the menu and setup the configuration options.
flatMenu = Menu(origin: CGPointMake(spacing, view.bounds.height - height - spacing))
flatMenu.direction = .Down
flatMenu.spacing = 8
flatMenu.buttonSize = CGSizeMake(120, height)
flatMenu.buttons = [btn1, btn2, btn3]
}
flatMenu
是Menu
材质库中的类型,是一个包含菜单中每个按钮的类。看来“原点”是控制页面定位的东西,但由于Menu
不是 UIView 子类,我不确定如何将其与自动布局一起使用。
public class Menu {
...
}