씬디의 블로그

[UIKit] UISwitch에 대한 UI 속성 본문

App/Swift

[UIKit] UISwitch에 대한 UI 속성

cyndi 2023. 12. 28. 13:00

Swift

https://developer.apple.com/documentation/uikit/uiswitch/1623686-seton

 

setOn(_:animated:) | Apple Developer Documentation

Sets the state of the switch to the on or off position, optionally animating the transition.

developer.apple.com

toggleButton.setOn(true, animated: true)

setOn(true)

: 스위치가 켜있는 상태

toggleButton.setOn(false, animated: true)

setOn(false)

: 스위치가 꺼져있는 상태

toggleButton.setOn(true, animated: true)

animated: true/false

스위치가 on, off 할 수 있게 동작 가능 여부

toggleButton.setOn(false, animated: true)
toggleButton.onTintColor = .red
toggleButton.thumbTintColor = .blue

onTintColor는 on되어있는 상태니까 제일 많이 보이는 영역의 색이라고 기억하면 될 것 같고

tumbTintColor는 엄지처럼 동그란 아이의 영역이라고 기억하면 될 것 같다

 

내맘이니까