본문 바로가기
iOS - 실무관련/iOS

textView행간 조절, 정렬, 폰트, 폰트 사이즈 설정하기

by print_soo 2022. 6. 8.
let explainText = "안녕하세요 \n iOSoo입니다."
        let style = NSMutableParagraphStyle() //단락 스타일 속성의 하위 속성 값을 변경하기 위한 개체입니다.
        style.lineSpacing = 5 //text 행간 조절
        style.alignment = .center //text 정렬
        let attributes = [NSAttributedString.Key.paragraphStyle : style]
        explanationTextView.attributedText = NSAttributedString(string: explainText, attributes: attributes)
        explanationTextView.font = .systemFont(ofSize: 14) //text 폰트와 폰트 사이즈