0

我知道 Snackbar 即将推出,但与此同时,使用 BottomNavigationBar 是否安全?

4

1 回答 1

0

我不会将 BottomNavigationBar(现在的 BottomTabBar)用作 Snackbar,因为它没有提供您想要的正确布局。我在开发中添加了一个示例项目 -> Programmatic 调用ControlView,它将向您展示如何使用 ControlView 类来创建 Snackbar。顺便说一句,ControlView 是 SearchBar 和 Toolbar 的父类,它将是创建 Snackbar 的基础。这是 UIViewController 代码。

class ViewController: UIViewController {
/// Reference for ControlView.
private var controlView: ControlView!

override func viewDidLoad() {
    super.viewDidLoad()
    prepareView()
    prepareControlView()
}

/// General preparation statements.
private func prepareView() {
    view.backgroundColor = MaterialColor.white
}

/// Prepares the controlView
private func prepareControlView() {
    controlView = ControlView(frame: CGRectMake(0, view.bounds.height - 56, view.bounds.width, 56))

    // Undo button.
    let undoButton: FlatButton = FlatButton()
    undoButton.pulseScale = false
    undoButton.pulseColor = MaterialColor.white
    undoButton.setTitle("UNDO", forState: .Normal)
    undoButton.setTitleColor(MaterialColor.teal.accent1, forState: .Normal)

    let label: UILabel = UILabel()
    label.text = "Archived"
    label.textColor = MaterialColor.white

    controlView.backgroundColor = MaterialColor.grey.darken4
    controlView.contentView.addSubview(label)
    controlView.rightControls = [undoButton]
    controlView.contentInsetPreset = .WideRectangle3

    view.addSubview(controlView)
    controlView.contentView.grid.views = [label]
}
}
于 2016-03-29T03:02:36.413 回答