iOS/코드조각

[iOS, Swift] UIView 터치범위 넓히기

검은참깨두유vm 2022. 10. 8. 10:22
반응형

iOS 15.5, Xcode 13.31, Swift 5, UIKit 환경에서 진행했습니다.

 

class CustomUIView: UIView {

    override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
        super.point(inside: point, with: event)
        
        let touchArea = bounds.insetBy(dx: -20, dy: -20)
        return touchArea.contains(point)
    }
}

 

반응형