iOS/iOS SeSAC 2기 TIL

iOS swift Label 요소

Developer-Michelle 2022. 7. 7. 10:12

resultLabel.backgroundColor = .clear 

라벨의 배경을 투명하게 하고 싶을 때

 

라벨에 내용을 많이 많이 쓰고 싶을 때

lines = 0 으로

 resultLabel.numberOfLines = 0 코드로 적거나

또는 인스펙터 속성창에서 설정 가능

 

 

라벨 안에 내용이 많을 경우 폰트사이즈를 작게 해주고 싶다면 ? autoshrink로 조절

 

 

textField 에도 응용:

글씨를 많이 쓸 때 작게 만들어준다 -> 아래에서 조절

 

 

textcolor 변경

myLabel.textColor = UIColor.red

 

label fontsize 변경

label.font = UIFont.systemFont(ofSize: 20.0)
label.font = UIFont.boldSystemFont(ofSize: 20.0)
label.font = UIFont.italicSystemFont(ofSize: 20.0)