I got it.
Here's the solution:
It seems odd this code is needed at all. I would think that Apple would enable the desired behavior without having to write code for it. Perhaps there's a setting that does exactly what I need that I don't know about.
extension UIButton {
open override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event)
next?.touchesBegan(touches, with: event)
print("UIButton touchesBegan")
open override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesMoved(touches, with: event)
next?.touchesMoved(touches, with: event)
print("UIButton touchesMoved")
open override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesEnded(touches, with: event)
next?.touchesEnded(touches, with: event)
print("UIButton touchesEnded")
open override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesCancelled(touches, with: event)
next?.touchesCancelled(touches, with: event)
print("UIButton touchesCancelled")
open override func touchesEstimatedPropertiesUpdated(_ touches: Set<UITouch>) {
super.touchesEstimatedPropertiesUpdated(touches)
next?.touchesEstimatedPropertiesUpdated(touches)
print("UIButton touchesEstimatedPropertiesUpdated")
I got it.
Here's the solution:
It seems odd this code is needed at all. I would think that Apple would enable the desired behavior without having to write code for it. Perhaps there's a setting that does exactly what I need that I don't know about.
extension UIButton {
open override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event)
next?.touchesBegan(touches, with: event)
print("UIButton touchesBegan")
open override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesMoved(touches, with: event)
next?.touchesMoved(touches, with: event)
print("UIButton touchesMoved")
open override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesEnded(touches, with: event)
next?.touchesEnded(touches, with: event)
print("UIButton touchesEnded")
open override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesCancelled(touches, with: event)
next?.touchesCancelled(touches, with: event)
print("UIButton touchesCancelled")
open override func touchesEstimatedPropertiesUpdated(_ touches: Set<UITouch>) {
super.touchesEstimatedPropertiesUpdated(touches)
next?.touchesEstimatedPropertiesUpdated(touches)
print("UIButton touchesEstimatedPropertiesUpdated")
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the
Apple Developer Forums Participation Agreement and Apple provided code is subject to the
Apple Sample Code License.
Forums
Apple Developer Program
Apple Developer Enterprise Program
App Store Small Business Program
MFi Program
News Partner Program
Video Partner Program
Security Bounty Program
Security Research Device Program