Closed sereisoglu closed 4 years ago
I'm not sure if this is true
You can check it out.
import LBTATools
class CustomButton: UIButton {
fileprivate let backgroundView = UIView(backgroundColor: .red)
init() {
super.init(frame: CGRect.zero)
stack(self.backgroundView).withWidth(200).withHeight(50)//.isUserInteractionEnabled = false
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let button = CustomButton()
button.addTarget(self, action: #selector(handleClick), for: .touchUpInside)
self.view.stack(
self.view.hstack(
button, alignment: .center
), alignment: .center
)
}
@objc fileprivate func handleClick() {
print("Clicked")
}
}
When the stack is used on inside a button, the button cannot be clicked.