Skip to content

Commit 2902d97

Browse files
committed
ObjectiveC Methods
1 parent 4c6257f commit 2902d97

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

SwiftDraw/NSImage+Image.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import AppKit
3434
import CoreGraphics
3535

3636
public extension NSImage {
37+
3738
convenience init?(svgNamed name: String, in bundle: Bundle = Bundle.main) {
3839
guard let image = Image(named: name, in: bundle) else { return nil }
3940

@@ -43,6 +44,11 @@ public extension NSImage {
4344
return true
4445
}
4546
}
47+
48+
@objc
49+
static func svgNamed(_ name: String, in bundle: Bundle = Bundle.main) -> NSImage? {
50+
NSImage(svgNamed: name, in: bundle)
51+
}
4652
}
4753

4854
public extension Image {

SwiftDraw/UIImage+Image.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import UIKit
3434

3535
public extension UIImage {
36+
3637
convenience init?(svgNamed name: String, in bundle: Bundle = Bundle.main) {
3738
guard let image = Image(named: name, in: bundle)?.rasterize(),
3839
let cgImage = image.cgImage else {
@@ -41,6 +42,11 @@ public extension UIImage {
4142

4243
self.init(cgImage: cgImage, scale: image.scale, orientation: image.imageOrientation)
4344
}
45+
46+
@objc
47+
static func svgNamed(_ name: String, in bundle: Bundle = Bundle.main) -> UIImage? {
48+
UIImage(svgNamed: name, in: bundle)
49+
}
4450
}
4551

4652
public extension Image {

0 commit comments

Comments
 (0)