views:

414

answers:

2

Hi, i am building a app in which if a UIImageView hits another something happens, i am using the CGRectIntersetsRect statement, i would like to make it as accurate as i can, at the moment i have about 8 UIImageViews inside this one UIImageView and i am detecting if something hits them 8 little views, i have decided that this is not a very accurate way to go about it. The problem is that the UIImageView the other UIImageView's are in, Its a Oval, so it is complicated, i have tryed masking it, using the image.layer.radius 10.0 or whatever the code is. but this doesnt actually transform the whole frame, is there any way to actually transform the whole frame so when a UIImageView hits the Oval shape then something happens?

if so could someone explain it to me.

Thanks Harry

A: 

A UIImageView's frame is a CGRect, a CGRect is a rectangle and a rectangle has no rounded properties.

Tom Irving
Okay, thanks. So i guess i just put loads of little UIImageviews in it again, or is there a CGOval?ill do some searching, thanks anywayharry
Harry
I've just had a quick idea, is there anyway to crop bits out of a UIImageView, eg it has 6 sides instead of 4?
Harry
It will always have 4 sides.
Tom Irving
Okay, thanks for help.
Harry
+1  A: 

Hi, this is really simple indeed. As a View, UIImageView has a layer and a layer has cornerRadius properties:

imageView.layer.cornerRadius = 5.0; imageView.layer.masksToBounds = YES;

eBuildy, iPhone specialists

eBuildy
make sure you import quartz or else it wont compile
Sheehan Alam
Yep true, also make sure to add the quartz framework in your project in addition of the #import "Qua..."BTW, someone told me this solution is not good in a UITableView bcoz the bad performance, is anyone has some inputs on it?
eBuildy