Sean Keane
05/01/2020, 5:24 PMKotlin subclass of Objective C class can't be imported
For this class
@ExportObjCClass
public class MyView: UIView {
private val helloWorldLabel = UILabel()
@OverrideInit
constructor(coder: NSCoder) : super(coder)
@OverrideInit
public constructor(frame: CValue<CGRect>) : super(frame) {
helloWorldLabel.apply {
text = "Hello World"
translatesAutoresizingMaskIntoConstraints = false
}
NSLayoutConstraint.activateConstraints(
listOf(
helloWorldLabel.centerXAnchor.constraintEqualToAnchor(this.centerXAnchor),
helloWorldLabel.centerYAnchor.constraintEqualToAnchor(this.centerYAnchor)
)
)
this.addSubview(this.helloWorldLabel)
}
@ObjCAction
fun layoutSubviews() {
}
}
Kris Wong
05/01/2020, 5:26 PMSean Keane
05/01/2020, 5:27 PMKris Wong
05/01/2020, 5:27 PMKris Wong
05/01/2020, 5:29 PMSean Keane
05/01/2020, 5:35 PM