I need to create a custom control with irregular shape, and only the visible area of that shape has the clickable area. For instance a "Star". Any help is really appreciated.
Asked
Active
Viewed 751 times
2 Answers
0
i think what you are looking for are irregularly shaped UIButtons, there is a good tutorial on this right here: Irregularly shaped UIButtons
Another way is to work with Quartz
and draw the buttons shape in the drawRect
function, someone asked this before and got an answer right here: Custom UIButton Shape without using an image
PS: next time try to google first, there is a ton of tutorials and how to's on such things :)

Community
- 1
- 1

Sebastian Flückiger
- 5,525
- 8
- 33
- 69
-
Thanks for your quick answer. Though I already had the links bookmarked, i was still looking for simpler and easily understandable solution. If nothing works, sure I'll mark your answer as accepted. – Avinazz Apr 17 '12 at 09:29
-
those solutions are understandable... show us what you have done so far and where you went wrong. it looks like you are looking for someone to make your code for you, that wont happen here. – Sebastian Flückiger Apr 17 '12 at 09:36
-
As I said earlier I already have the same links. The thing is I am pretty much new to iOS and I am given task to create a POC for a project. There are several challenging areas where I am doing my research. Point is, the problem mentioned above is of least priority, thus I didn't follow ur solution for time being. btw, I am Android developer since couple of years and trying my hands on iOS lately. Also I respect the ethics of such forum and have no intentions of acquiring entire code as solutions. – Avinazz Apr 17 '12 at 10:11
-
just set the background image with a transparent background and make it a custom button type. It's too easy – Nick Turner Apr 10 '13 at 15:06
0
Just implement the hit Test Method to check if the touch is in your "Star"
- (UIView *) hitTest:(CGPoint) point withEvent:(UIEvent *)event {
if ([self pointInside:point withEvent:event]) {
return scrollView;
}
return nil;
}
-
Tried the above mentioned snippet but failed. I have created a customview with Imageview of irregular shape inside it. I hope I am not doing this wrong coz I am new at iOS. – Avinazz Apr 17 '12 at 09:26
-