Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is it possible to make triangle UIView?

i want to display triangle shape UIView instead of using normal UIView.is it possible?

like image 998
senthilM Avatar asked Mar 05 '11 07:03

senthilM


1 Answers

A UIView is always a rectangular shape, you can't alter that. However, you could perhaps get the effect you want by using CALayer masking. Make a UIView and apply a custom mask to it, whereby the mask has the appropriate data in it for a triangle. Then any actual content you put in your UIView will only be visible in the appropriate 'triangle' shaped area.

To make your mask layer, you can either use an image (e.g. a png) or use core graphics to draw a triangle.

There's tons of info on this sort of stuff in the Apple Quartz 2D docs.

There's an example here:

http://cocoadev.com/MaskingACALayer

See also this stack overflow question:

Learning Core Graphics

There's also info about this stuff in Apple's API docs for UIView and CALayer.

like image 190
occulus Avatar answered Nov 05 '22 01:11

occulus