ํ‹ฐ์Šคํ† ๋ฆฌ ๋ทฐ

 

 

 

์œ„ ์‚ฌ์ง„ ๊ฐ™์€ drop down ์ฒ˜๋Ÿผ 

๋ถ€๋ชจ๋ทฐ์˜ ํ”„๋ ˆ์ž„์€ ํšŒ์ƒ‰์ด๊ณ  ์ž์‹๋ทฐ๋Š” ์ดˆ๋ก์ƒ‰ ์˜์—ญ์ผ ๋•Œ

 

๋ถ€๋ชจ๋ทฐ์˜ ์˜์—ญ์ธ (3)์˜ ์ž์‹๋ทฐ๋Š” ํ„ฐ์น˜๊ฐ€ ๋˜๋Š”๋ฐ (4)๋Š” ๋ถ€๋ชจ์˜ ์˜์—ญ ๋ฐ–์ด๋ผ ํ„ฐ์น˜๊ฐ€ ์•ˆ๋ฉ๋‹ˆ๋‹ค.

 

์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด์„œ ๋ทฐ ์ž์ฒด์—์„œ ํ„ฐ์น˜๋ฅผ ๊ฐ์ง€ํ•˜๋Š” ๋ฉ”์†Œ๋“œ๋ฅผ ์žฌ์ •์˜ํ•˜๋Š” ๋ฐฉ๋ฒ•์ด ์žˆ์Šต๋‹ˆ๋‹ค.

 

 

 

 

class CustomUIView: UIView {
    override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
        if !self.clipsToBounds && !self.isHidden && self.alpha > 0.0 {
            let subviews = self.subviews.reversed()
            for member in subviews {
                let subPoint = member.convert(point, from: self)
                if let result: UIView = member.hitTest(subPoint, with:event) {
                    return result
                }
            }
        }
        return super.hitTest(point, with: event)
    }
    override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
        return super.point(inside: point, with: event)
    }
}

 

 

 

ํ„ฐ์น˜ ํฌ์ธํŠธ๋ฅผ ์ž์‹๋ทฐ์˜ ์ขŒํ‘œ๊ณต๊ฐ„์œผ๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ๊ณผ์ •์ž…๋‹ˆ๋‹ค.

clipToBounds๊ฐ€ false์ด๋ฉฐ ๋ทฐ๊ฐ€ ์ˆจ๊ฒจ์ ธ ์žˆ์ง€ ์•Š๊ณ  ํˆฌ๋ช…๋„๊ฐ€ 0์ด ์•„๋‹๋•Œ ํ„ฐ์น˜๋กœ ๋ณ€ํ™˜ํ•ด์ฃผ๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

 

 

 

 

 

 

์ถœ์ฒ˜

https://stackoverflow.com/questions/53542133/touch-event-does-not-register-outside-of-a-child-uiview-that-partially-extends-o

 

 

 

๋Œ“๊ธ€