100 days of swiftui: 24
https://www.hackingwithswift.com/100/swiftui/24
totalAmount
를 빨강색으로 나타내기 Section("Total amount") {
Text(totalAmount, format: .currency(code: "USD"))
.foregroundStyle(tipPercentage == 0 ? .red : .black)
}
코드 파일
https://github.com/treesofgroo/Ios-WeSplit/commit/35c2f236d128f194eb265c6453dbdcca8ccd72e3
FlagImage
로 대체하기// ...
Button {
guessFlag(selectedAnswer: number)
} label: {
FlagImage(flagName: countries[number])
}
// ...
struct FlagImage: View {
let flagName: String
var body: some View {
Image(flagName)
.clipShape(RoundedRectangle(cornerRadius: 20))
.shadow(radius: 10)
}
}
코드 파일
https://github.com/treesofgroo/Ios-GuessFlags/commit/7449f18837ab0e6445e62f3794976bf7f7da6548
struct BlueTitle: ViewModifier {
var text: String
func body(content: Content) -> some View {
VStack {
Text(text)
.font(/*@START_MENU_TOKEN@*/.title/*@END_MENU_TOKEN@*/)
.foregroundStyle(.blue)
content
}
}
}
extension View {
// ...
func blueTitle(text: String) -> some View {
modifier(BlueTitle(text: text))
}
}
코드 파일
https://github.com/treesofgroo/Ios-studying/commit/8ebaed88dc93a89eb5139a55a64be3e2e8fbfabc