swift 获取网络加载图片的宽度高度的方法

let imageSource = CGImageSourceCreateWithURL(URL(string: content)! as CFURL, nil)
if imageSource == nil {
    return
 }
 if let result = CGImageSourceCopyPropertiesAtIndex(imageSource!, 0, nil) as? Dictionary {
 print("\(result)")
 if let width = result["PixelWidth"] as? CGFloat, let height = result["PixelHeight"] as? CGFloat {
     self.height = height / 2.0
   }
}

你可能感兴趣的:(swift 获取网络加载图片的宽度高度的方法)