I'm trying to create an extension to UIView with a static initializer (for example like new
). In my old Objective-C projects I would create a Category with the following implementation:
+ (instancetype)autoLayout {
UIView *view = [self new];
view.translatesAutoresizingMaskIntoConstraints = NO;
return view;
}
But I can't find a way to do this in swift. I thought about creating a normal class function:
class func autolayout() {
let view = self.init()
view.translatesAutoresizingMaskIntoConstraints = false
}
.. but what should be the return type?