Is there a way to verify if a CGPoint
is inside a specific CGRect
.
An example would be:
I\'m dragging a UIImageView
and I want t
In objective c you can use CGRectContainsPoint(yourview.frame, touchpoint)
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch* touch = [touches anyObject];
CGPoint touchpoint = [touch locationInView:self.view];
if( CGRectContainsPoint(yourview.frame, touchpoint) ) {
}else{
}}
In swift 3 yourview.frame.contains(touchpoint)
override func touchesBegan(_ touches: Set, with event: UIEvent?) {
let touch:UITouch = touches.first!
let touchpoint:CGPoint = touch.location(in: self.view)
if wheel.frame.contains(touchpoint) {
}else{
}
}