Roen의 iOS 개발로그

UITextView의 알 수 없는 공백을 없애보자

by Steady On

UITextView의 알 수 없는 공백

TextView의 상하좌우로 알 수 없는 빈여백이 있어서 이걸 어떻게 없앨 수 있는지 알아보았다.

 

textContainerInset; Apple developer Document

The inset of the text container's layout area within the text view's content area.
text view의 컨텐츠 영역 안의 text container의 레이아웃 영역의 inset.

This property provides text margins for text laid out in the text view. By default the value of this property is (8, 0, 8, 0).
이 속성은 text view에 배치된 텍스트에 대한 텍스트 여백을 제공합니다. 기본적으로 이 속성의 값은 (8, 0, 8, 0) 입니다.

이 속성 때문에 text의 위,아래로 8의 여백이 생겨있었고, view hierachy에서 확인할 수 있었다.

 

 

lineFragmentPadding; Apple developer Document

The value for the text inset within line fragment rectangles.
선 조각 사각형 내의 text inset을 위한 값(?)

The padding appears at the beginning and end of the line fragment rectangles. The layout manager uses this value to determine the layout width. The default value of this property is 5.0. Line fragment padding is not designed to express text margins. Instead, you should use insets on your text view, adjust the paragraph margin attributes, or change the position of the text view within its superview.
선 조각 직사각형의 시작과 끝에 padding이 나타난다. 레이아웃 매니저는 이 값을 사용하여 레이아웃 너비를 결정한다. 이 프로퍼티의 기본 값은 5.0이다. 선 조각 padding은 text의 margins을 표현하도록 설계되지 않았다. 대신에, text View의 inset을 사용하거나 문단 margin 속성을 조정하거나 해당 뷰 내의 text view의 위치를 변경해야 한다.

사실 정확하게 선 조각 직사각형(line fragment rectangle)이 뭔지는 모르겠는데, view hierachy에서 text를 감싸고 있는 직사각형을 가리킨다고 판단했다. 그렇게 보면, 이 사각형의 시작과 끝, 그러니까 leading과 trailing에 약간의 여백이 있는 것을 볼 수 있다. 이 속성의 기본 값이 5여서 전체적으로 약간 들여쓰기 한 것 처럼 보였던 것이다. 그래서 마찬가지로 이 속성도 0으로 맞춰주면 text를 감싼 여백이 모두 사라진다.

 

 

 

블로그의 정보

Roen의 iOS 개발로그

Steady On

활동하기