iOS
[iOS] Label에 취소선 긋기
thoonk:
2020. 12. 24. 20:38
반응형
ToDo 앱을 만들다가 Label에 취소선을 긋는 방법을 알아봤습니다.
할 일이 완료되면 제목에 취소선을 그어서 표시할 때 사용할 수 있습니다.
extension String {
// 취소선 긋기
func strikeThrough() -> NSAttributedString {
let attributeString = NSMutableAttributedString(string: self)
attributeString.addAttribute(NSAttributedString.Key.strikethroughStyle, value: NSUnderlineStyle.single.rawValue, range: NSMakeRange(0,attributeString.length))
return attributeString
}
}
참조:
Apple Developer Documentation
developer.apple.com
반응형