其实我认为这个很简单,我错过了一些东西。
我正在创建 UIView 的子类,而不是像这样从 ViewController 将其添加为子视图:
rateus = RateFrameWork(AppID: "asdasds", BackGroundColor: UIColor.blueColor())
self.addSubView(rateus)
我正在尝试从子类中添加它,这是我到目前为止所尝试的:
class RateFrameWork: UIView
1)来自超级初始化编码器(剂量工作)
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
superview?.addSubview(self)
}
2)从init方法(剂量工作)
init?(AppID: String!, BackGroundColor: UIColor!)
super.init(frame: CGRect(x: 0 , y: 0, width: UIScreen.mainScreen().bounds.size.width , height:UIScreen.mainScreen().bounds.size.height))
superview?.addSubview(self)
有什么建议么?如何将其添加为来自其自己的子类的子视图?