오늘은 롱 프레스 메뉴를 만들어보겠습니다. 버튼을 하나 만들고요. @IBOutlet var myButton: UIButton! viewDidLoad 에 인터렉션을 만들고 버튼에 추가해주세요. let btnInteraction = UIContextMenuInteraction(delegate: self) myButton.addInteraction(btnInteraction) 그러면 이런식으로 델리게이트 상속 받으라고 나옵니다. 빨간원 누르고 Fix 눌러서 델리게이트와 함수를 추가해주세요. 이 함수가 추가되셨을텐데 여기 안에다가 메뉴를 만들어서 넣으면 됩니다. func contextMenuInteraction(_ interaction: UIContextMenuInteraction, configurationFo..
UITableView 를 Swipe 해서 cell 을 remove 해보겠습니다. 코드로 작성해야합니다. func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) { if editingStyle == .delete { dataArray.remove(at: indexPath.row) tableView.deleteRows(at: [indexPath], with: .fade) } else if editingStyle == .insert { } } 이렇게 작성하면 끝입니다. 잘 나오네요. 전체 코드입니다. import UIKit class ViewCon..
UITableView 의 cell 사이에 이렇게 구분선 이 나오죠. 저 gray line 을 없애보겠습니다. 먼저 스토리보드에서는 테이블뷰를 선택한 후에 Separator 를 None 으로 변경하면 됩니다. 코드로는 import UIKit class ViewController3: UIViewController { @IBOutlet var myTableView: UITableView! override func viewDidLoad() { super.viewDidLoad() // 테이블뷰 라인 없애기 myTableView.separatorStyle = .none } } 이렇게 하면 됩니다. 끝입니다.