What would be the way to draw a triangular button on the iPhone. It would be nice if I could also change its parameters (backgroundcolor, font etc..) as with the regular buttons.
Ideally I would like equilateral triangles.
What would be the way to draw a triangular button on the iPhone. It would be nice if I could also change its parameters (backgroundcolor, font etc..) as with the regular buttons.
Ideally I would like equilateral triangles.
You could transform you button/view using core animation 3d transform. I am not sure how it will look like inside of it. but you surely can get a triangle form view. You can apply a rotation in 3D (arround X or Y axis, not Z) with a large enough angle that it looks like a triangle.
An alternative approach is to make it look like triangular. You probably not need it TO BE triangular. So, maybe by setting a triangular look like image or maybe by hiding part of the button with (2D) rotated view or layer.
If you are not changing too much the background images of your buttons, I suggest to put in the resources, some .png file you create using photoshop for example, in which the triangular part has full opacity and the remaining areas are full transparent.
Then create UIImage using the method : [UIImage imageNamed:file_path_inside_resources_folder] and set it as background image for your button.
Note that you need to do the work only once, since the UIButton will resize the picture according to its own frame dimensions.
Regards Meir Assayag
take a look at this post: http://iphonedevelopment.blogspot.com/2010/03/irregularly-shaped-uibuttons.html