Mercurial > public > geoquiz
comparison GeoQuiz/GuessThePopulationView.swift @ 27:3f4b366d476d
add flag layout settings
author | Dennis C. M. <dennis@denniscm.com> |
---|---|
date | Thu, 10 Nov 2022 09:26:48 +0100 |
parents | 425078c01194 |
children | 6d574bd1644f |
comparison
equal
deleted
inserted
replaced
26:425078c01194 | 27:3f4b366d476d |
---|---|
5 // Created by Dennis Concepción Martín on 29/9/22. | 5 // Created by Dennis Concepción Martín on 29/9/22. |
6 // | 6 // |
7 | 7 |
8 import SwiftUI | 8 import SwiftUI |
9 | 9 |
10 struct GuessThePopulationView: View { | 10 struct GuessThePopulationView: View, GameView { |
11 @StateObject var gameController = CountryGameController() | 11 @StateObject var gameController = CountryGameController() |
12 | 12 |
13 @Environment(\.managedObjectContext) var moc | 13 @Environment(\.managedObjectContext) var moc |
14 | 14 |
15 var body: some View { | 15 var body: some View { |
33 | 33 |
34 THE SOLUTION: | 34 THE SOLUTION: |
35 Using `UIImage(contentsOfFile: path)` images aren't cached. | 35 Using `UIImage(contentsOfFile: path)` images aren't cached. |
36 */ | 36 */ |
37 | 37 |
38 let flag = gameController.correctAnswer.value.flag | 38 let flagPath = getFlagPath(forName: gameController.correctAnswer.value.flag) |
39 let flagPath = Bundle.main.path(forResource: flag, ofType: "png")! | 39 |
40 Image(uiImage: UIImage(contentsOfFile: flagPath)!) | 40 Image(uiImage: UIImage(contentsOfFile: flagPath)!) |
41 .renderingMode(.original) | 41 .renderingMode(.original) |
42 .resizable() | 42 .resizable() |
43 .scaledToFit() | 43 .scaledToFit() |
44 .clipShape(RoundedRectangle(cornerRadius: 20)) | 44 .clipShape(RoundedRectangle(cornerRadius: 20)) |