ios(SwiftUI)
SwitfUI) 버튼이 Text 레이블 외의 영역에서도 클릭되게 하기
E.I.T.U
2022. 9. 6. 18:11
Button(action: {print("Customer clicked")}) {
NavigationLink(destination: CustomerMainView()) {
Text("주문하기\n\nᐅ")
.bold()
.foregroundColor(Color.white)
.background(Color(hex: "#80B3FF"))
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)
}
}.background(Color.blue)
스위프트 UI에서 버튼을 만들고 클릭을 해보면 텍스트 부분밖에 액션이 잡히지 않는 현상을 볼 수 있다
분명 frame 으로 영역을 크게 잡아줘도 전혀 액션이 잡히지 않는데
이때 버튼이 아닌 내부 레이블의 크기를 늘려줘야 한다