uibutton触发边界事件
UIControlEventTouchDragInside
UIControlEventTouchDragOutside
UIControlEventTouchDragEnter
UIControlEventTouchDragExit
UIControlEventTouchUpInside
UIControlEventTouchUpOutside[btn addTarget:self.action:@selector(btnDragged:withEvent:).forControlEvents:UIControlEventTouchDragOutside];
- (void)btnDragged:(UIButton*)sender withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
CGFloat boundsExtension = 25.0f;
CGRect outerBounds = CGRectInset(sender.bounds, -1 * boundsExtension, -1 * boundsExtension);
BOOL touchOutside = !CGRectContainsPoint(outerBounds, [touch locationInView:sender]);
if (touchOutside)
{//出边界了
}
}Last updated