简体   繁体   中英

iOS UIButton event when its frame at negative position from superview

I have a view A has frame (100, 200, 320, 200). I add a UIButton B to view A with frame (0, -100 , 50, 50). How can I receive TouchUpInside event of button B.

I tried some ways on Internet

A.clipsToBound = NO;

on view AI implemented hitTest:withEvent to return a received view is B.

But when I touch on button B, it NOT go on function hitTest and so it do nothing.

Why can I do it? I read on Apple document about UIView, it said that set clipsToBound is NO, problem solved, but I don't think so. Is problem about my negative position y of my button B (-100).

B isn't on the view. it's 100 points above it. How is a user supposed to interact with it?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM