视图之外点击移除视图

-(void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    UITouch *touch = [touches anyObject];
    
    CGPoint point = [touch locationInView:touch.view];
    if(!CGRectContainsPoint(self.calendarView.frame, point)){
        [self removeFromSuperview];
    }
}
相关文章
相关标签/搜索