我不知道为什么找不到这个课程。我看过其他与此类似的帖子,但是我的代表的命名惯例不应该干扰swift。我已经尝试了所有我能想到的东西,但我仍然不知道为什么无法找到SelectButton。
有什么想法吗?
import UIKit
import QuartzCore
protocol SelectButtonDelegate {
func willSelectButton(button: SelectButton)
}
class SelectButton: UIButton {
var delegate: SelectButtonDelegate?
let normalColor = UIColor(white: 0, alpha: 0.2)
let selectedColor = UIColor(white: 0, alpha: 0.4)
let recessedColor = UIColor(white: 0, alpha: 0.5)
init(frame: CGRect, title: String) {
super.init(frame: frame)
backgroundColor = normalColor
setTitle(title, forState: .Normal)
setTitleColor(UIColor(white: 1, alpha: 0.2), forState: .Normal)
setTitleColor(UIColor(white: 1, alpha: 0.7), forState: .Selected)
layer.cornerRadius = 3
bk_addEventHandler({ (object) -> Void in
UIView.animateWithDuration(0.1, animations: { () -> Void in
self.backgroundColor = self.recessedColor
})
}, forControlEvents: .TouchDown)
bk_addEventHandler({ (object) -> Void in
UIView.animateWithDuration(0.1, animations: { () -> Void in
self.backgroundColor = self.currentColor()
})
}, forControlEvents: .TouchUpOutside)
bk_addEventHandler({ (object) -> Void in
UIView.animateWithDuration(0.1, animations: { () -> Void in
self.switchState()
self.backgroundColor = self.currentColor()
})
}, forControlEvents: .TouchUpInside)
}
func currentColor() -> UIColor {
if selected == true {
return selectedColor
}
return normalColor
}
func switchState() {
if selected == true {
selected = false
}
else {
if delegate != nil {
delegate!.willSelectButton(self)
}
selected = true
}
}
func deselect() {
selected = false
UIView.animateWithDuration(0.1, animations: { () -> Void in
self.backgroundColor = self.currentColor()
})
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
}
答案 0 :(得分:0)
当我从我正在处理的回购中撤出时,显然目标从未设定过。因此,找不到该文件。