How to crop the image using UIBezierPath?

后端 未结 8 1665
我在风中等你
我在风中等你 2020-11-30 23:16

I want to get the image from the UIBezierpath closed path(See the image). I draw the image on the UIView using drawRect method and als

8条回答
  •  粉色の甜心
    2020-11-30 23:41

    iDev's answer is excellent, but if you need transparent background, then except UIGraphicsBeginImageContext(view.bounds.size); you should use

    UIGraphicsBeginImageContextWithOptions(view.bounds.size, NO, 1.0);
    

    By default image context is created with opaque == YES, so you have to change it to NO.

提交回复
热议问题