How can I make an UIImage programmatically?

前端 未结 5 1773
自闭症患者
自闭症患者 2021-02-07 02:26

This isn\'t what you probably thought it was to begin with. I know how to use UIImage\'s, but I now need to know how to create a \"blank\" UIImage using:

CGRect sc

5条回答
  •  囚心锁ツ
    2021-02-07 02:46

    Swift version:

    extension UIImage {
    
        static func emptyImage(with size: CGSize) -> UIImage? {
            UIGraphicsBeginImageContext(size)
            let image = UIGraphicsGetImageFromCurrentImageContext()
            UIGraphicsEndImageContext()
            return image
        }
    
    }
    

提交回复
热议问题