Reputation: 5089
I have a simple UIView subclass that looks like this:
import UIKit
class AngleViewManager: UIView {
class AngleView: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = UIColor.red
}
init(first: CGPoint, second: CGPoint, third: CGPoint) {
// setup
super.init(frame: CGRect(dimensions))
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
}
When I initialize an AngleView
instance within AngleViewManager
like
AngleView(firstPoint, secondPoint, thirdPoint)
,
the background color is not red, and setting a breakpoint in the overridden init shows that it is never called even though I am explicitly calling it in my custom initializer which does get called successfully.
Am I missing something obvious?
Upvotes: 0
Views: 917
Reputation: 63271
You're calling the super class's (UIView
) implementation of init(frame: CGRect)
.
Just change it to self.init(frame: frame)
Upvotes: 2