class CustomView: UIView {
var subViewColor:UIColor
var subViewMessage:String
override init(frame:CGRect) {
super.init(frame:frame)
}
init(subViewColor:UIColor,subViewMessage:String){
self.subViewColor = subViewColor
self.subViewMessage = subViewMessage
super.init()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
Mam klasy gdzie chcę użytkownik może zainicjować widoku niestandardowego albo poprzez nadanie właściwości jak:Zastąp metoda init UIView w szybkim
let myView = CustomLoadingView(initialize properties here)
Jeśli użytkownik nie chce zainicjować własną rękę właściwości, chcę zainicjować CustomLoadingView
użyciu właściwości domyślnych ...
let myView = CustomLoadingView() // this should initialize using default value
jednak z tego, otrzymuję ten błąd:
Must call a designated intializer of the superclass UIView
Działa to tylko dla mnie, jeśli nazywam 'self.init (frame: frame)' jako pierwszą rzeczą w 'convenience init' metoda – Joseph