CGRect.init() - 参数标签与任何可用的重载不匹配
问题描述:
我需要帮助解决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
答
使用此代码 -
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
希望它能帮助!
使用自动完成或检查文档以查找可用的过载。 'CGRect'没有没有参数标签的初始化器,因为你需要告诉编译器在什么坐标系中/你需要什么单位来初始化CGRect。 –