简体   繁体   中英

UIView in the shape of a light bulb

如何使用CAShapeLayer创建灯泡形状的视图?

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;

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM