Possible Duplicate:
Simple way of using irregular shaped buttons
I found examples about creating a rect or round UIButton.
Is possible to create an UIButton with a particular shape (e.g. a heart, a star and so on)?
How?
Possible Duplicate:
Simple way of using irregular shaped buttons
I found examples about creating a rect or round UIButton.
Is possible to create an UIButton with a particular shape (e.g. a heart, a star and so on)?
How?
The easiest way to accomplish that is using:
UIButton *myButton=[UIButton buttonWithType:UIButtonTypeCustom];
[myButton setFrame:CRectMake( 0, 0, imWidth, imHeight)];
[myButton setBackgroundImage:[UIImage imageNamed:@"shabadabada.png"] forState:UIControlStateNormal];
And that would get you a simple button ... though it is not actually shaped like a "shabadabada" (:P) it will be a squared button.
To do a truly custom shaped "button" you would have to implement from the UIView class:
-(void) drawRect:(CGRect)rect;
And you would have to draw your shape point by point, here's a simple guide on doing this.
And also respond to the following methods:
– touchesBegan:withEvent:
– touchesMoved:withEvent:
– touchesEnded:withEvent:
– touchesCancelled:withEvent:
Or just to:
– addGestureRecognizer: