Setting A CGContext Transparent Background

后端 未结 8 767
长发绾君心
长发绾君心 2020-12-08 09:15

I am still struggling with drawing a line with CGContext. I have actually go to line to draw, but now I need the background of the Rect to be transparent so the existing ba

8条回答
  •  北荒
    北荒 (楼主)
    2020-12-08 10:01

    Init a context with opaque == false, Swift 3

    UIGraphicsBeginImageContextWithOptions(size, false, UIScreen.main.scale) 
    

    opaque

    A Boolean flag indicating whether the bitmap is opaque. If you know the bitmap is fully opaque, specify true to ignore the alpha channel and optimize the bitmap’s storage. Specifying false means that the bitmap must include an alpha channel to handle any partially transparent pixels.

提交回复
热议问题