Skip to content

Commit

Permalink
update to support swift4+
Browse files Browse the repository at this point in the history
  • Loading branch information
gaoxiang committed Sep 20, 2018
1 parent 05c6fca commit d7d73bc
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Source/iOS/UIImage+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ extension UIImage {

/// Convert to data
func cache_toData() -> Data? {
#if swift(>=4.2)
return hasAlpha
? self.pngData()
: self.jpegData(compressionQuality: 1.0)
? pngData()
: jpegData(compressionQuality: 1.0)
#else
return hasAlpha
? UIImagePNGRepresentation(self)
: UIImageJPEGRepresentation(self, 1.0)
#endif
}
}

0 comments on commit d7d73bc

Please sign in to comment.