[IDLE-450] Foundation수정 및 사이드 이펙트 해결 #92
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
변경된 점
UIFont 중앙배치 문제 해결
폰트의 크기및 lineHeight값에 상관없이 항상 폰트를 중앙에 위치시키는 작업이 필요했다.
예를들어 아래 영상을 보면, 버튼이 Focus된 경우 폰트가 바뀐다, 그런데 잘못된 로직으로인해 폰트가 중앙을 유지하지 못하는 문제가 발생했다.
default.mp4
의도치 않게 글자가 요동치는 것을 확인할 수 있다.
UIFont분석
UIFont의 경우 베이스라인으로부터 위로 가장 멀리떨어진 문자의 길이를 ascender라는 변수에 저장한다.
베이스라인으로 부터 가장 아래에 떨어진 길이를(ex 알파벳p) descender에 보통 음수로 저장한다.
LineHeight이란 다행 문자열에 대해 베이스라인 사이의 간격을 의미하며 아래 식을 만족한다.
※ leading은 추가적인 여백을 의미한다.
해당 프로젝트의 모든 UILabel에는 NSAttributedString이 삽입된다.
아래코드는 Label에 지정된 타이포그래피가 가지는 속성을 반환한다.
베이스라인을 정확한 수치만큼 이동시켜 문제를 해결할 수 있었다.
default.mp4