//
// testGeomerty.swift
// GeoMertyReader_Tutorial
//
// Created by devdepot on 2021/04/28.
//
import SwiftUI
enum Index {
case one,two,three
}
struct testGeomerty: View {
@State var index : Index = .one
var body: some View{
GeometryReader{ rate in
HStack{
Spacer()
VStack(alignment: .center){
Button(action: {
print("1번이 클릭 되었습니다.")
withAnimation{
self.index = .one
}
}, label: {
Text("1")
.font(.largeTitle)
.frame(width: 100,height:rate.size.height/3)
.padding(.horizontal,self.index == .one ? 100 : 0)
.background(Color.red)
.foregroundColor(Color.white)
})
Button(action: {
print("2번이 클릭 되었습니다.")
withAnimation{
self.index = .two
}
}, label: {
Text("2")
.font(.largeTitle)
.frame(width: 100,height:rate.size.height/3)
.padding(.horizontal,self.index == .two ? 100 : 0)
.background(Color.blue)
.foregroundColor(Color.white)
})
Button(action: {
print("3번이 클릭 되었습니다.")
withAnimation{
self.index = .three
}
}, label: {
Text("3")
.font(.largeTitle)
.frame(width: 100,height:rate.size.height/3)
.padding(.horizontal,self.index == .three ? 100 : 0)
.background(Color.green)
.foregroundColor(Color.white)
})
}//vstack
Spacer()
}//hstack
}
.background(Color.yellow)
.edgesIgnoringSafeArea(.all)
}
}
struct testGeomerty_Previews: PreviewProvider {
static var previews: some View{
testGeomerty()
}
}
'IOS > SwiftUI' 카테고리의 다른 글
(SwiftUI)12.커스톰 탭뷰 (0) | 2021.04.28 |
---|---|
(SwiftUI)11.탭뷰 (0) | 2021.04.28 |
(SwiftUI)09.리스트뷰 (0) | 2021.04.27 |
(SwiftUI)08. 동적 뷰 넣기, 스택 연습,Alert (0) | 2021.04.27 |
(SwiftUI)07.Stack 정리 (0) | 2021.04.27 |