【问题标题】:How to add a UIButton on top of UITabBar inside a UITableView如何在 UITableView 内的 UITabBar 顶部添加 UIButton
【发布时间】:2019-02-02 14:19:35
【问题描述】:

有谁知道我如何在 UITableView 中创建一个 UIButton(约束高度:35,前导:0,尾随:0 和 UITabBar 的底部空间:0),该 UITableView 的底部间距与实现的 UITabBar 的底部间距为零UITableViewController?

到目前为止我尝试了什么:

    let btn = UIButton()
    btn.setTitle("Test Button text", for: .normal)
    btn.tintColor = UIColor.white
    btn.backgroundColor = UIColor.darkGray
    self.view.addSubview(btn)
    btn.translatesAutoresizingMaskIntoConstraints = false
    btn.leadingAnchor.constraint(equalTo: self.view.leadingAnchor, constant: 0).isActive = true
    btn.bottomAnchor.constraint(equalTo: self.view.bottomAnchor, constant: 0).isActive = true
    btn.trailingAnchor.constraint(equalTo: self.view.trailingAnchor, constant: 0).isActive = true
    btn.heightAnchor.constraint(equalToConstant: 35).isActive = true

【问题讨论】:

    标签: swift uitableview uibutton constraints


    【解决方案1】:

    子类 Uitabbar 并将其分配给您的标签栏。然后在类中添加您的按钮代码。不要忘记取消选中 tabbar 的 cliptobound 属性。

    【讨论】:

    • 你能这么好心告诉我怎么做吗?我仍然是 swift 的初学者。
    猜你喜欢
    • 2011-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-01
    • 2011-12-17
    • 2014-05-17
    • 2011-03-02
    • 2017-01-31
    相关资源
    最近更新 更多