IOS would like to ask CAShapeLayer to create a straight line. How to respond to gestures

CAShapeLayer plus UIBezierPath draws an oblique line. You can"t click on it. Ask the boss for advice

Jun.15,2022

on his parent view UIView, respond to the gesture.

because UIView can respond to events, CALayer cannot.

UIKit uses UIResponder as the response object to respond to and process events passed by the system. UIApplication, UIViewController, UIView, and all subclasses of UIView (including UIWindow) are responders responder, through inheritance.

the interface for handling various events and event delivery is defined in UIResponder, while CALayer inherits NSObject directly and has no corresponding interface for handling events.

on the official document, it is written very clearly

https://developer.apple.com/d...

0


Layer is designed not to respond to events, so you need to respond to events, handle them in the touch event in view, or add your own gestures

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e6ff81-46063.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e6ff81-46063.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?