CUICatalog: Invalid asset name supplied:

问题

出现这个问题是因为图片名称为空,虽然只是警告,但是对于一个强迫症的我来说,不能忍受

UIImage(named: “”)

解决

#定义UIImage扩展
extension UIImage {
  @objc class func KS_Name(named:String) -> UIImage? {
    ///去空 
        if named.isEmpty {
          return nil
        }
        let img = self.KS_Name(named:named)
        if img == nil {
/// 可以打印缺少资源
            DLog(named)
            return nil
        }
        return img
    }
}

///runtime 替换
 swizzingClass(sel: #selector(UIImage.init(named: )), of: #selector(UIImage.KS_Name(named:)), in: UIImage.self)

你可能感兴趣的:(CUICatalog: Invalid asset name supplied:)