font
: .largetTitle 등 서식 설정foregroundColor
: 글자 색background
: 글자 배경 색(프레임 색)lineLimit
: text의 길이가 긴 경우 표시할 줄 설정multilineTextAlignment
: 기본은 .leading, 여러줄일 경우 정렬 설정lineSpacing
: 줄 간 여백 설정truncationMode
: text의 길이가 길 때 전부 표시할 수 없을 시 .head, .middle, .tail 중 설정 가능하며 기본값은 .tailLabel("표시할 text", systemImage: "이미지")
systemImage의 종류가 많기 때문에 앱을 설치한 뒤 확인하는 것이 좋다 (설치 링크)
HStack {
Image(systemName: "person")
Text("User Profile")
}
.font(.largeTitle)
//위와 동일
Label("User Profile", "systemImage: "person")
.font(.largeTitle)
HStack {
Image("logo")
.resizable()
.aspectRatio(1.0, contentMode: .fit)
.frame(width: 60)
.clipShape(Circle())
.overlay {
Circle()
.stroke(lineWidth: 2)
.forgroundColor(.blue)
}
Text("KxCoding")
.font(.largeTitle)
}
//위와 동일
Label {
//오른쪽 표시
Text("KxCoding")
.font(.largeTitle)
} icon: {
//왼쪽 표시
Image("logo")
.resizable()
.aspectRatio(1.0, contentMode: .fit)
.frame(width: 60)
.clipShape(Circle())
.overlay {
Circle()
.stroke(lineWidth: 2)
.forgroundColor(.blue)
}
}
-> UI가 단순하면 Label이 좋고, 커스텀 뷰 리턴 시 차이가 없음. 단, 네비게이션바나 툴바에 임베드하면 Label이 좀 더 좋음
왜냐하면 labelStyle
모디파이어를 사용 가능하기 때문
.toolbar {
Button {
} label: {
Label("User Profile", systemImage: "person")
.labelStyle(.titleAndIcon)
}
}
.body
가 기본Text("Monospaced")
.font(.system(.largeTitle, design: .monospaced))
Text("Rounded")
.font(.system(.largeTitle, design: .rounded))
Text("Serif")
.font(.system(.largeTitle, design: .serif))
Text("50pt Font")
.font(.system(size: 50))
//weight 조정
Text("Black")
.font(.system(size: 50, weight: .black)
Text("Ultra Light")
.font((.system(size: 50))
.fontWeight(.ultraThin)
Text("Underline")
.underline(active: Bool, color: nil)
active
파라미터로 밑줄 표시 여부 전달color
파라미터로 색 설정, nil일경우 검정색