Reputation: 14113
I want to draw UIButton
in following shape :
I have cut the image, so the edges are not straight. Please consider them straight. Also the bottom right corner is as shown. It is cut in quarter of circle.
I am not able to draw this shape for UIButton
. How to do this?
Upvotes: 0
Views: 738
Reputation: 5953
Interesting question. I did a search and found two simple solutions that seem much simpler than the GB2. They override either hitTest:withEvent: or pointInside:withEvent: to take into account if the current pixel is transparent or not. So just take your image, set the lower right corner to transparent in a graphics editor, and use one of these classes.
http://iphonedevelopment.blogspot.com/2010/03/irregularly-shaped-uibuttons.html and http://oleb.net/blog/2009/10/obshapedbutton-non-rectangular-buttons-on-the-iphone/
Upvotes: 1
Reputation: 1066
I got the same problem, I found a different UIBUtton libraries and solved this
search for:
GB2ShapeCache
and implement if you don't find it I could upload it and I give you the link.
You only put the library in your UIBUtton and it will work
I hope it helps :)
Upvotes: 1
Reputation: 6064
[self.myButton setBackgroundImage:[UIImage imageNamed:@"myOddlyShapedImage"] forState:UIControlStateNormal];
Upvotes: 1