1

how can I create a view in the shape of a light bulb with CAShapeLayer?

rdurand
  • 7,342
  • 3
  • 39
  • 72
Aviv Paz
  • 1,051
  • 3
  • 13
  • 28
  • 2
    possible duplicate of [Triangular UIView or UIImageView](http://stackoverflow.com/questions/21776253/triangular-uiview-or-uiimageview), exact same principle – Cyrille May 28 '15 at 07:52

2 Answers2

3

There is a Tool called PaintCode,you can put image or draw path on it.It will return a path.

Then you create a CAShaperLayer with this path. Then set mask layer

yourview.layer.mask = yourLayer;
yourview.layer.masksToBounds = YES;
Leo
  • 24,596
  • 11
  • 71
  • 92
2

You can't accomplish this using an UIView's frame property. You could do this using a CALayer like CAShapeLayer. You have to set it's path property accordingly.

Iulian Onofrei
  • 9,188
  • 10
  • 67
  • 113