This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct ContentView: View { | |
| var imageNames: [String] = ["img_0", "img_1"] | |
| var body: some View { | |
| AnimatedImage(imageNames: imageNames) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct AnimatedImage: View { | |
| @State private var image: Image? | |
| private let imageNames: [String] | |
| var body: some View { | |
| Group { | |
| image? | |
| .resizable() | |
| .scaledToFit() | |
| }.onAppear(perform: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct AnimatedImage: View { | |
| @State private var image: Image? | |
| private let imageNames: [String] | |
| var body: some View { | |
| image? | |
| .resizable() | |
| .scaledToFit() | |
| } | |
| } |