设置条形按钮项Swift的约束?

时间:2017-04-12 04:20:56

标签: swift constraints

我正在以编程方式添加这样的栏按钮项:

    let button = UIButton.init(type: .custom)
    button.setImage(UIImage(named: "Bar Chart Filled-50"), for: UIControlState.normal)
    button.addTarget(self, action: #selector(self.statButtonPressed), for: UIControlEvents.touchUpInside)
    button.frame = CGRect(x: 0, y: 0, width: 40, height: 40)
    let barButton = UIBarButtonItem(customView: button)
    navItem.rightBarButtonItem = barButton

我希望它在页面的导航栏中垂直居中。我将如何以编程方式执行此类操作。

图片:img

0 个答案:

没有答案