How to check if a uiimage is blank? (empty, transparent)

后端 未结 6 2075
说谎
说谎 2020-12-31 23:07

which is the best way to check whether a UIImage is blank?
I have this painting editor which returns a UIImage; I don\'t want to save this imag

6条回答
  •  醉话见心
    2020-12-31 23:22

    I just encountered the same problem. Solved it by checking the dimensions:

    Swift example:

    let image = UIImage()
    
    let height = image.size.height
    let width = image.size.height
    
    if (height > 0 && width > 0) {
        // We have an image
    } else {
        // ...and we don't
    }
    

提交回复
热议问题