【发布时间】:2019-04-14 23:27:21
【问题描述】:
我创建了这样一个类:
class number1: UIScrollView {
init() {
super.init(frame: CGRect(x: 9, y: 780, width: 1024, height: 267))
self.contentSize = CGSize(width: 100, height: 267)
self.backgroundColor = UIColor.clear
self.autoresizingMask = UIView.AutoresizingMask(rawValue: UIView.AutoresizingMask.RawValue(UInt8(UIView.AutoresizingMask.flexibleWidth.rawValue)))
//followed by do blablabla I dont want in my new class
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
现在我想要一个类似于我的第一堂课但没有 blablabla 的第二堂课。
class number2: number1 {
override init() {
super.init()
self.frame = CGRect(x: 400, y: 10, width: 196, height: 500)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
我正在这样做,但不知道如何删除“blablabla”。最简单的方法是从 UIScrollView 而不是类 number1 继承 init。该怎么做?
【问题讨论】:
标签: swift class multiple-inheritance