How to disable TouchUpInside Action outside the boundary of button

你说的曾经没有我的故事 提交于 2019-12-06 15:53:32

Create action of signature

- (IBAction)buttonPressed:(id)sender forEvent:(UIEvent*)event{
//your code
} 

for your button

Find out touch location using this answer UIButton TouchUpInside Touch Location

Check if that location is contained in your CGPath using

- (IBAction)buttonPressed:(id)sender forEvent:(UIEvent*)event{
  //find location point using above answer link
  if([button.layer.mask containsPoint: location])
  {
   //proceed with the code
  }
} 

it returns a bool if it contains point.

i.e if it contains point you can proceed otherwise you can return.

Hope it helps :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!