Swift interface builder问题
1. 新建一个view文件,如何用interface builder 将控件连接到code?
2. 如何调整控件间的距离?
2. 手动将button和action加入view
class RatingControl: UIView {
// MARK: Initialization
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
let button = UIButton(frame: CGRect(x: 0,y: 0,width: 44, height: 44))
button.backgroundColor = UIColor.redColor()
button.addTarget(self, action: "rattingButtonTapped", forControlEvents: .TouchDown)
addSubview(button)
}
// MARK: Button actoin
func ratingButtonTapped(button: UIButton) {
print("Button pressed!")
}
}