How to limit recognition of iPhone hard drive inside a circular image?

I try to put a circular image on the iPhone view, and then consume taps inside the circle, but not outside. The problem I am facing is that when I place the UIImageView on the screen in Interface Builder, it seems to me that it is limited to a rectangular shape. I tried using a circle image with an area outside the circle that remained transparent, but the image as a whole is still rectangular, so when it fits into the UIImageView and connects to gesture recognition, it still captures taps outside the circle itself.

The image below shows what I mean. The blue dots represent the outer border of the UIImageView that contains the image. Recognizing the tap tap gesture is currently related to this UIImageView, but as you can see, there is little space in the corners of the UIImageView that is not covered by the circular image. Is there a way to associate a UIImageView with a non-rectangular shape or to place an image in a view without using a UIImageView and still be able to connect a tap recognition?

walter image with transparent background on UIImageView http://img237.imageshack.us/img237/2164/walterheadshot.png

I'm new to iPhone graphics, but does anyone have any ideas on this or can they point me in the right direction?

Thank!

+5
1

, :

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    CGFloat halfSize = [self bounds].size.width * 0.5f;
    CGPoint location = [[touches anyObject] locationInView:self];
    location.x -= halfSize;
    location.y -= halfSize;
    CGFloat squaredDistanceFromCenter = location.x * location.x + location.y + location.y;
    if (squaredDistanceFromCenter < (halfSize * halfSize)) {
        NSLog(@"Within circle :)");
    } else {
        NSLog(@"Not within circle :(");
    }
}
+4

All Articles