//在创建的UIButton子类里,重写hitTes方法
-(UIView*)hitTest:(CGPoint)pointwithEvent:(UIEvent*)event
{
CGRectbtnFrame =CGRectInset(self.frame, -30, -30);//正数缩小,负数扩大
if(CGRectContainsPoint(btnFrame,point)) //判断点击点是否在按钮的范围内
{
returnself;
}
return[superhitTest:pointwithEvent:event]; //不在
}
网友评论