2017-08-02 34 views
-6

我需要帮助解决Swift 3中的这个错误! enter image description hereCGRect.init() - 参数标签与任何可用的重载不匹配

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 
+4

使用自动完成或检查文档以查找可用的过载。 'CGRect'没有没有参数标签的初始化器,因为你需要告诉编译器在什么坐标系中/你需要什么单位来初始化CGRect。 –

回答

1

更换

CGRect(0, 0, 40, 40) 

CGRect(x: 0, y: 0, width: 40, height: 40) 
+0

谢谢你的作品!我是新来的迅速 – Techitout

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 

希望它能帮助!

相关问题