Develop Note: Swift
✢ Notes
- Launch page
- Add a Launch Screen storyboard.
- Design Launch page on Launch Screen storyboard.
- Check up Launch setting of project.
- Open Info.plist.
- Find key: Launch screen interface file base name.
- Check the Launch screen is the storyboard that created for Launch screen.
If create Launch Screen storyboard by add file in Xcode, the Launch screen will be set to Launch Screen storyboard you just added automatically. If not, set to the storyboard you want to use.
- Run ► again.
Button border
button1.layer.cornerRadius = 4 button2.layer.cornerRadius = 6 //setup border style button1.layer.borderColor = UIColor.white.cgColor button1.layer.borderWidth = 2.0TableView:
UITableViewDelegate,UITableViewDataSource- Set how many rows in table
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return foods.count //data counts } Draw every cell view
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! IngredientTableViewCell //Setup cell .... return cell }- Set selected style of cell
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { //setup action when select cell //Show .actionSheet or .alert or any else ... //Show checkmark let cell = tableView.cellForRow(at: indexPath) ... cell?.accessoryType = self.selected ? .checkmark : .none } - Edit cell of table
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) { if editingStyle == .delete { //delete item of model } } Edit swipe action on cell
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? { //swipe action: share let share = UITableViewRowAction(style: .default, title: "Share") { ... } //swipe action: add let add = ... return [share, add, ...] }
- Set how many rows in table