如何在Swift中调用指定的超类初始值设定项

Dan*_*tar 3 objective-c uiview swift

在Objective-C中,初始化器中有这种标准模式来调用超类的指定初始化器.

例如:

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}
Run Code Online (Sandbox Code Playgroud)

在Swift类中进行相同初始化的标准方法是什么?

Tom*_*art 11

像这样

init(frame: CGRect) {
    super.init(frame: frame)
    // Initialization code
}
Run Code Online (Sandbox Code Playgroud)