用Quartz 2d勾画图形可能大家都会,但是如何让我们勾画的图形响应事件呢?有人会说用坐标计算啊,但是有时候对不规则的图形,这个办法不使最简单的做法,下面的代码可以帮你很容易实现这一点。
//只是代码而已 , 如果有兴趣的同学 我们可以私下探讨 email:zhuolaiqiang@mail.com
//原帖地址  http://blog.csdn.net/diyagoanyhacker/article/details/6608840


- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
  UITouch *touch = [[event allTouches] anyObject];
  CGPoint location = [touch locationInView:self.view];
  // Depending on your code, you may need to check a different view than self.view




  // You should probably check the docs for the arguments of this function--
  // It's been a while since I last used it
  if (CGPathContainsPoint(yourCircle, nil, location, nil)) {
    // Do something swanky
  } else {
    // Don't do teh swank
  }
}

相关文章:

  • 2021-08-18
  • 2022-02-06
  • 2021-12-13
  • 2022-12-23
  • 2022-12-23
  • 2021-07-10
猜你喜欢
  • 2021-10-21
  • 2021-09-17
  • 2022-12-23
  • 2022-01-20
  • 2021-10-11
  • 2022-12-23
  • 2022-02-16
相关资源
相似解决方案