Skip to content

Commit f45961f

Browse files
author
Simon Bachmann
authored
Merge pull request #28 from jostster/master
Add ability to use images as confetti
2 parents 2a5797c + 543b26f commit f45961f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Diff for: Sources/ConfettiSwiftUI.swift

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public enum ConfettiType:CaseIterable, Hashable {
2020
case shape(Shape)
2121
case text(String)
2222
case sfSymbol(symbolName: String)
23+
case image(String)
2324

2425
public var view:AnyView{
2526
switch self {
@@ -35,6 +36,8 @@ public enum ConfettiType:CaseIterable, Hashable {
3536
return AnyView(Text(text))
3637
case .sfSymbol(let symbolName):
3738
return AnyView(Image(systemName: symbolName))
39+
case .image(let image):
40+
return AnyView(Image(image).resizable())
3841
default:
3942
return AnyView(Circle())
4043
}
@@ -91,6 +94,8 @@ public struct ConfettiCannon: View {
9194
switch confetti {
9295
case .shape(_):
9396
shapes.append(AnyView(confetti.view.foregroundColor(color).frame(width: confettiSize, height: confettiSize, alignment: .center)))
97+
case .image(_):
98+
shapes.append(AnyView(confetti.view.frame(maxWidth:confettiSize, maxHeight: confettiSize)))
9499
default:
95100
shapes.append(AnyView(confetti.view.foregroundColor(color).font(.system(size: confettiSize))))
96101
}

0 commit comments

Comments
 (0)