1

I have made a Custom Circle View, How to Detect Some Portion or Part of Circle.I have Tried this using touches

- (BOOL)validatePoint:(CGPoint)myPoint
{
    // calculate how far from centre we are with Pythagorean
    // √ a2 + b2
    CGFloat a = abs(myPoint.x - (self.bounds.size.width/2));
    CGFloat b = abs(myPoint.y - (self.bounds.size.height/2));
    CGFloat distanceFromCentre = sqrt(pow(a,2) + pow(b,2));

    if((distanceFromCentre > self.minRadiusSize) && (distanceFromCentre < radius)){
        return YES;
    }else{
        // not inside doughnut
        return NO;
    }
}

But its Detecting Entire my View.

4

1 に答える 1

1
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
    BOOL transparent=NO;

    CGPoint touchLocation = [event  locationInView:yourViewName];

    if(CGRectContainsPoint(yourViewName.frame, touchLocation))
    {
        NSLog(@"Found =%d",i);

        transparent=YES;
    }

    return transparent;
}

これにより、ビューでタップしたかどうかが返されます。

于 2013-08-12T12:44:44.990 に答える