How to convert UIView to UIImage without background?

后端 未结 1 1880
春和景丽
春和景丽 2021-01-17 13:14

I have UIView that contain a pin image and a label, as we know UIView is rectangle so if I convert UIView to UIImage,UIImage is also rectangle, I want make UIImage like the

1条回答
  •  逝去的感伤
    2021-01-17 13:44

    A UIImage is always rectangular. What you can play with is the opacity in your views. If you make everything except your pin image transparent, it will seem as if you just have an image of the pin.

    Use:

    view.backgroundColor = [UIColor clearColor];
    

    to make your view's background transparent.

    0 讨论(0)
提交回复
热议问题