UIView is always a rectangular shape, you cannot change this. However, you can get the effect you want using CALayer masking. Create a UIView and apply a custom mask to it, in which the mask has the corresponding data for the triangle. Then any actual content that you put in your UIView will be displayed only in the corresponding area of ββthe "triangle".
To make a mask layer, you can use an image (for example, png) or use kernel graphics to draw a triangle.
There are tons of information about such things in Apple Quartz 2D docs .
Here is an example:
http://cocoadev.com/MaskingACALayer
See also this question:
Basic Graphics Training
There is also information about this in the Apple API docs for UIView and CALayer.
source
share