You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
ToggleSwitch 란
SwiftUI
의Toggle()
을 사용하면UIKit
의UISwitch
에서처럼 사용자가true
이거나false
상태 사이를 이동할 수 있습니다.Toggle()
의 현재 값을 저장하는 데 사용할@State Boolean
속성을 정의해야 합니다. 그런 다음 이것을 사용하여 필요에 따라 다른view
를 표시하거나 숨길 수 있습니다.버튼이
Toggle()
될 때마다if
문을 사용하여 텍스트를 지정해 줄 수 있습니다.위 코드와 동일한 화면을 보여주는 [삼항연산자](https://seons-dev.tistory.com/36) 를 사용할 수 도 있겠죠?
Toggle에 색상 부여
toggleStyle()
수정자를 사용하여Toggle Switch
를 만드는 데 사용되는색상
을 사용자 지정할 수 있습니다.이것은
Toggle view
가accentColor()
와 함께 작동하지 않기 때문에, 색상을 다시 지정하는 유일한 방법입니다삼항연산자를 사용해서 토글이 활성화 되어있을때와 그렇지 않을때에 따라 텍스트를 다르게 해줄수도 있어여!
Beta Was this translation helpful? Give feedback.
All reactions