Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我使用 画一个圆圈CGContext,是否可以使用触摸拖动这个圆圈。有没有办法检查触摸区域是否包含绘制的圆圈?
CGContext
我想UIControl用圆形或盒子形状创建自定义。
UIControl
你可以做的是制作那个圆圈的矩形
CGRect myRect=CGRectMake(center.x-radius, cemter.y-radius, 2r, 2r);
并通过选择触摸点来检测该矩形内的触摸
CGPoint touch=[[touches anyObject]locationInView:self]; if(CGRectContainsPoint(myRect,touch )) { //code here for true condition }