123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- import UIKit
- public extension UIImage {
-
- func scaledImage(_ scale: CGFloat) -> UIImage? {
- let outputSize = size * scale
- let renderer = UIGraphicsImageRenderer(size: outputSize)
- return renderer.image(actions: {_ in })
- }
-
- func scaledImage(length: CGFloat, with quality: CGFloat) -> Data? {
- let edge = size.width > size.height ? size.height : size.width
- let outputSize = size * (length / edge)
-
- let renderer = UIGraphicsImageRenderer(size: outputSize)
- return renderer.image(actions: {_ in }).jpegData(compressionQuality: quality)
- }
- }
- public extension UIImage {
- static var defaultAvatar: UIImage? {
- return UIImage(named: "defaultAvatar")
- }
-
- static var photoPlaceholder: UIImage? {
- return UIImage(named: "photoPlaceholder")
- }
-
- struct Navigation {
- public static var background: UIImage? {
- return UIImage(named: "navigation-background")?.resizableImage(withCapInsets: UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0),
- resizingMode: .stretch)
- }
-
- public static var blackBackground: UIImage? {
- return UIImage(named: "navigation-background-black")?.resizableImage(withCapInsets: UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0),
- resizingMode: .stretch)
-
- }
-
- public static var right: UIImage? {
- return UIImage(named: "navigation-right")?.resizableImage(withCapInsets: UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0),
- resizingMode: .stretch)
- }
-
-
-
- public static var verticalPoints: UIImage? {
- return UIImage(named: "navigation-vertical-points")?.resizableImage(withCapInsets: UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0),
- resizingMode: .stretch)
- }
- }
-
- struct PhotoDetail {
- public static var purchaseBackground: UIImage? {
- return UIImage(named: "purchase-background")?.resizableImage(withCapInsets: UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0),
- resizingMode: .stretch)
- }
- }
- }
|