我知道Snackbar即将推出,"但与此同时,使用BottomNavigationBar是否安全?
答案 0 :(得分:0)
我不会将BottomNavigationBar(现在是BottomTabBar)用作Snackbar,因为它没有提供您想要的正确布局。我在开发中添加了一个示例项目 - >程序化调用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]
}
}