-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContentView.swift
More file actions
49 lines (43 loc) · 1.5 KB
/
ContentView.swift
File metadata and controls
49 lines (43 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
// ContentView.swift
// Shared
//
// Created by kotomi tahkahashi on 2022/02/16.
//
import SwiftUI
struct ContentView: View {
var array: [[String]] = []
@State var flowers: [LotFrower] = [
LotFrower(currentflowerName: "flower_tullip", isPushed: false),
LotFrower(currentflowerName: "flower_tullip", isPushed: false),
LotFrower(currentflowerName: "flower_tullip", isPushed: false),
LotFrower(currentflowerName: "flower_tullip", isPushed: false)
]
var currentFlower: String = "appleFrpwer"
var body: some View {
ZStack {
Color.green
.ignoresSafeArea()
.opacity(0.15)
Group {
ForEach(1...flowers.count, id: \.self) {flowerIndex in
Image("\(currentFlower)")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 150, height: 150)
.offset(x: flowers[flowerIndex - 1].x, y: flowers[flowerIndex - 1].y)
.opacity(flowers[flowerIndex - 1].isPushed ? 0 : 1 )
.onTapGesture {
print("\(flowerIndex)つ目の花を消しました。")
flowers[flowerIndex - 1].isPushed = true
}
}
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}