일정관리 앱에서 많이 사용하는 스트라이크 라인 설정법
2018. 8. 2. 00:52
일정관리 앱에서 흔히 볼 수 있는, 완료 항목에 줄을 긋는 방법
cell.planTitleLabel.text = plans![indexPath.row].title
if plans![indexPath.row].check == true {
cell.planCheckImage.image = UIImage(named: "ico_checkOn")
cell.planTitleLabel.textColor = UIColor(hex: checkOnTextColor)
let attributedString = NSMutableAttributedString(string: plans![indexPath.row].title)
attributedString.addAttribute(NSAttributedStringKey.strikethroughStyle, value: 1, range: NSMakeRange(0, attributedString.length))
attributedString.addAttribute(NSAttributedStringKey.strikethroughColor, value: UIColor(hex: checkOnTextColor), range: NSMakeRange(0, attributedString.length))
cell.planTitleLabel.attributedText = attributedString
} else {
cell.planCheckImage.image = UIImage(named: "ico_checkOff")
cell.planTitleLabel.textColor = UIColor(hex: checkOffTextColor)
let attributedString = NSMutableAttributedString(string: plans![indexPath.row].title)
attributedString.removeAttribute(NSAttributedStringKey.strikethroughStyle, range: NSMakeRange(0, attributedString.length))
cell.planTitleLabel.attributedText = attributedString
}
적용 예:
'프로그래밍 > iOS' 카테고리의 다른 글
[Swift 4] 간단한 내용 저장할 때 UserDefaults 설정 (0) | 2018.08.22 |
---|---|
[Swift 4] 노티피케이션을 이용한 간단한 날짜 변화 체크 (0) | 2018.08.22 |
[Realm] Realm 에서 primaryKey id 이용해서 가장 마지막 데이터 가져오기 (0) | 2018.08.14 |
[Swift 4] Custom Segue로 화면 전환을 가로 방향으로 하는 법 (0) | 2018.08.03 |
일정관리 앱에서 많이 사용하는 스트라이크 라인 설정법 (0) | 2018.08.02 |
화면의 세로 사이즈로 디바이스 구별 (0) | 2018.07.25 |