Change size of UIBarButtonItem (image) in Swift 3

前端 未结 6 2044
没有蜡笔的小新
没有蜡笔的小新 2020-12-14 07:51

I am trying to change the size of some icons in my navBar, but I am a little confused as to how to do this? My code so far is:

func setUpNavBarButtons() {
          


        
6条回答
  •  时光取名叫无心
    2020-12-14 08:46

    In the end I did it like this and it worked:

    let moreButton = UIButton(frame: CGRect(x: 0, y: 0, width: 35, height: 35))
    moreButton.setBackgroundImage(UIImage(named: "ic_more_vert_3"), for: .normal)
    moreButton.addTarget(self, action: #selector(TableViewController.handleMore), for: .touchUpInside)
    self.navigationItem.rightBarButtonItem = UIBarButtonItem(customView: moreButton)
    

    Answer from: Change width of a UIBarButtonItem in a UINavigationBar in swift

提交回复
热议问题