How i set the background color in UIView using CGContext?

前端 未结 2 2060
渐次进展
渐次进展 2021-02-20 01:10

I have developed the application in which i want to set the background color of UIView which is already set on UIViewController.The code is below,

@implementatio         


        
2条回答
  •  囚心锁ツ
    2021-02-20 01:27

    Swift 3

    UIGraphicsBeginImageContextWithOptions(size, true, UIScreen.main.scale)
    let context = UIGraphicsGetCurrentContext()
    context?.setFillColor(UIColor.green.cgColor)
    let image = UIGraphicsGetImageFromCurrentImageContext()
    UIGraphicsEndImageContext()
    return image
    

提交回复
热议问题