此代码:
import UIKit
import CircleMenu
class ViewController: UIViewController {
let button = CircleMenu(
frame: CGRect(x: 200, y: 200, width: 50, height: 50),
normalIcon:"icon_menu",
selectedIcon:"icon_close",
buttonsCount: 4,
duration: 4,
distance: 120)
button.delegate = self
button.layer.cornerRadius = button.frame.size.width / 2.0
view.addSubview(button)
}
给出了错误"期望的声明"在button.delegate = self
前面。
为什么?
答案 0 :(得分:0)
典型地,
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
button.delegate = self
button.layer.cornerRadius = button.frame.size.width / 2.0
view.addSubview(button)
}
}