AutoLayout 설정글꼴 적용Background Image 설정체크박스 변경추가하기 View 추가![]() | ![]() |
|---|
Content Hugging Prioiry 이다. Content Hugging Priority 는 두개의 프로퍼티를 갖고 있다, Horizontal 와 Vertical. 각각의 UI Component 마다 0부터 1000까지 설정을 할 수 있다. Label이 Contriant를 상하좌우 다 걸었다고 가정을 하면, 아래의 그림(왼쪽그림) 처럼 보일것이다. (중간그림)Content Hugging Priority 는 이런 문제는 해결(?), 방지(?) 해준다.![]() | ![]() | ![]() |
|---|
EF_다이어리체를 다운받아서 적용했다. 적용해보니 나쁘지 않은것 같다!UISwitch는 비주얼적으로 뭔가 안이쁘고 실질적으로 체크박스가 더 직관적이라는 생각이 들어서, UISwitch를 지우고, 버튼을 사용해서 체크 박스로 만들었다.UIButton 를 생성 한뒤에, 기본 이미지를 SF Symbols 에서 square를 사용했다. (빈 네모칸), 그리고 클릭시에는, 이미지가 체크가 들어가 있는 박스로 변경하였다. UIswitch 일때도 마찬가지지만, CustomCell 에 있는거기 때문에, delegate패턴을 사용해서, 버튼이 클릭시에는 ViewController에서 작업을 수행한다.UiSwitch 에서 사용했던 방식 그대로 사용했다.Todo 인스턴스의 isCompleted를 true에서 false, false에서 True로 변경한다reloadData()를 통해 변경된 정보로 다시 테이블을 변환한다.// ToDoTableViewCell.Swift
protocol TableViewDelegate {
func buttonIsClicked(index: Int)
}
class ToDoTableViewCell: UITableViewCell {
...
var delegate : TableViewDelegate?
@IBAction func CheckBoxButtonClicked(_ sender: UIButton) {
self.delegate?.buttonIsClicked(index: index)
}
...
// ViewController.swift
extension ViewController: TableViewDelegate {
func buttonIsClicked(index: Int) {
list[index].isCompleted = list[index].isCompleted ? false : true
self.MyTableView.reloadData()
}
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = MyTableView.dequeueReusableCell(withIdentifier: ToDoTableViewCell.identifier, for: indexPath) as! ToDoTableViewCell
let target = list[indexPath.row]
...
if target.isCompleted == true {
cell.Title.attributedText = cell.Title.text?.strikeThrough()
cell.CheckBoxButton.setImage(UIImage(systemName: "checkmark.square"), for: .normal)
}else{
cell.CheckBoxButton.setImage(UIImage(systemName: "square"), for: .normal)
if let text = cell.Title.text {
let attributedString = NSMutableAttributedString(string: text)
attributedString.removeAttribute(.strikethroughStyle, range: NSMakeRange(0, attributedString.length))
cell.Title.attributedText = attributedString
}
}
UITextField, UITextView ,UIDatePicker, UINavigationBar 에 대해서 알아보자UITextField 는 An object that displays an editable text area in your interface.

UITextView 는 A scrollable, multiline text region.

UIDatePicker 는 A control for inputting date and time values.

UINavigationBar 는 Navigational controls that display in a bar along the top of the screen, usually in conjunction with a navigation controller..
Title, LeftBarButtonItem, RightBarButtonItemLeftBarButtonItem 은 취소, RightBarButtonItem 은 추가, Title은 새로운 투두추가, 이런식으로 Cutomize가 가능하다. TitleNavigationItem에서 프로퍼티로 변경하는 것이다.@IBOutlet weak var titleNavigationItem: UINavigationItem!
titleNavigationItem.leftBarButtonItem?.action = #selector(self.dismissLeftButton)
titleNavigationItem.rightBarButtonItem?.action = #selector(self.addRightBUtton)

Todo 구조체의 데이터를 추가해서, 더 많은 정보를 갖을 수 있게 변경해야 한다.