🍎 Swift/오류 잡아라!
[오류] Label .center 설정하면 텍스트가 떨리는 오류
솔비님
2024. 8. 14. 12:19
오류 내용
: textAlignment = .center 작성 시 레이블이 업데이트 될 때마다 노출되는 숫자의 자간이 계속 바뀌어서 미친듯이 떨리는 현상 발생🙂↔️
시도 1 (실패)
Label 레이아웃에서 width를 지우고 leading trailling 값으로 재설정 → 안됨
시도 2 (실패)
textAlignment 값을 .left 로 변경하고 최대한 center로 보이게 width를 딱 맞게 설정 → 떨림은 사라졌으나 11:11.11 같은 자간이 좁은 텍스트 노출 시 왼쪽으로 치우쳐짐
시도 3 (성공🌈)
스텍오버플로우에서 찾은 문서
iOS Prevent timer UILabel 'shaking' when numbers change
I have a UILabel which shows the output of a timer in the format MM:ss:SS (minutes, seconds, centiseconds), however it "shakes" from left to right as the width of the centiseconds changes - "11" is
stackoverflow.com
시스템에서 생성된 글꼴 중 고정폭 글꼴을 사용하면 흔들리지 않는다는 사실 발견!!!!!
ㅋㅋㅋㅋㅋ 해결완료 오예 ✌🏻