Skip to content

Commit a0addb0

Browse files
author
ApptekStudios
committed
Add convenience swiftUI initialisers
1 parent edc1e7d commit a0addb0

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

Library/SwiftUI/SwiftUI.Color+ColorResource.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,10 @@ public extension SwiftUI.Color {
2222
self.init(resource.name, bundle: resource.bundle)
2323
}
2424
}
25+
26+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
27+
public extension ColorResource {
28+
var color: SwiftUI.Color {
29+
SwiftUI.Color(self)
30+
}
31+
}

Library/SwiftUI/SwiftUI.Font+FontResource.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,10 @@ public extension SwiftUI.Font {
2323
self = .custom(resource.fontName, size: size)
2424
}
2525
}
26+
27+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
28+
public extension FontResource {
29+
func font(size: CGFloat) -> SwiftUI.Font {
30+
SwiftUI.Font(self, size: size)
31+
}
32+
}

Library/SwiftUI/SwiftUI.Image+ImageResource.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,10 @@ public extension SwiftUI.Image {
2222
self.init(resource.name, bundle: resource.bundle)
2323
}
2424
}
25+
26+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
27+
public extension ImageResource {
28+
var image: SwiftUI.Image {
29+
SwiftUI.Image(self)
30+
}
31+
}

0 commit comments

Comments
 (0)