視圖之外點擊移除視圖

-(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];
    }
}
相關文章
相關標籤/搜索