我需要帮助解决Swift 3中的这个错误! enter image description here
let button = UIButton(frame: CGRect(0, 0, 40, 40)) // Create new button & set its frame
button.setImage(UIImage(named: "refresh"), for: []) // Assign an image
barButton.customView = button // Set as barButton's customView
答案 0 :(得分:3)
替换
CGRect(0, 0, 40, 40)
与
CGRect(x: 0, y: 0, width: 40, height: 40)
答案 1 :(得分:0)
使用此代码 -
let button = UIButton(frame: CGRect(x: 0, y: 0, width: 40, height: 40)) // Create new button & set its frame
button.setImage(UIImage(named: "refresh"), for: []) // Assign an image
barButton.customView = button // Set as barButton's customView
希望它有所帮助!