File tree 2 files changed +21
-26
lines changed
Sources/SwiftUIKit/Images
2 files changed +21
-26
lines changed Original file line number Diff line number Diff line change 8
8
9
9
import Foundation
10
10
11
- #if canImport(AppKit)
11
+ #if canImport(UIKit)
12
+ import UIKit
13
+
14
+ public extension UIImage {
15
+
16
+ /// Create a resized copy of the image.
17
+ func resized( to size: CGSize ) -> UIImage ? {
18
+ UIGraphicsBeginImageContextWithOptions ( size, false , scale)
19
+ draw ( in: CGRect ( origin: CGPoint . zero, size: size) )
20
+ let result = UIGraphicsGetImageFromCurrentImageContext ( )
21
+ UIGraphicsEndImageContext ( )
22
+ return result
23
+ }
24
+ }
25
+ #elseif canImport(AppKit)
12
26
import AppKit
13
27
14
28
public extension NSImage {
@@ -26,23 +40,6 @@ public extension NSImage {
26
40
}
27
41
#endif
28
42
29
-
30
- #if canImport(UIKit)
31
- import UIKit
32
-
33
- public extension UIImage {
34
-
35
- /// Create a resized copy of the image.
36
- func resized( to size: CGSize ) -> UIImage ? {
37
- UIGraphicsBeginImageContextWithOptions ( size, false , scale)
38
- draw ( in: CGRect ( origin: CGPoint . zero, size: size) )
39
- let result = UIGraphicsGetImageFromCurrentImageContext ( )
40
- UIGraphicsEndImageContext ( )
41
- return result
42
- }
43
- }
44
- #endif
45
-
46
43
public extension ImageRepresentable {
47
44
48
45
/// Create a resized copy of the image with a new height.
Original file line number Diff line number Diff line change 8
8
9
9
import SwiftUI
10
10
11
- #if canImport(AppKit )
12
- import class AppKit . NSImage
11
+ #if canImport(UIKit )
12
+ import class UIKit . UIImage
13
13
14
14
/**
15
15
This typealias helps bridging UIKit and AppKit when working
16
16
with images in a multi-platform context.
17
17
*/
18
- public typealias ImageRepresentable = NSImage
19
- #endif
20
-
21
- #if canImport(UIKit)
22
- import class UIKit. UIImage
18
+ public typealias ImageRepresentable = UIImage
19
+ #elseif canImport(AppKit)
20
+ import class AppKit. NSImage
23
21
24
22
/**
25
23
This typealias helps bridging UIKit and AppKit when working
26
24
with images in a multi-platform context.
27
25
*/
28
- public typealias ImageRepresentable = UIImage
26
+ public typealias ImageRepresentable = NSImage
29
27
#endif
30
28
31
29
public extension Image {
You can’t perform that action at this time.
0 commit comments