Skip to content

Commit d7d73bc

Browse files
author
gaoxiang
committed
update to support swift4+
1 parent 05c6fca commit d7d73bc

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Source/iOS/UIImage+Extensions.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,14 @@ extension UIImage {
2222

2323
/// Convert to data
2424
func cache_toData() -> Data? {
25+
#if swift(>=4.2)
2526
return hasAlpha
26-
? self.pngData()
27-
: self.jpegData(compressionQuality: 1.0)
27+
? pngData()
28+
: jpegData(compressionQuality: 1.0)
29+
#else
30+
return hasAlpha
31+
? UIImagePNGRepresentation(self)
32+
: UIImageJPEGRepresentation(self, 1.0)
33+
#endif
2834
}
2935
}

0 commit comments

Comments
 (0)