Swift4 Day74:做一個待辦事項Todoey4

Swift4 / iOS11 / 2017.01.12–01.29 ChameleonSwipeCellKit應用

Alice
Daily Swift
5 min readJan 29, 2018

--

Todoey完整程式碼

寒假開始了,旅遊也結束了,回來開始coding吧!

今天做事的時候都有開著toggl計時,寫code4小時medium1.5小,還打了爐石哈哈,實際的時間真的跟身體感覺差很多,轉眼就快12點啦😂

SwipeCellKit 2.0.1

  1. cd 到資料夾; open Podfile -a Xcode
  1. 在Xcode中pod ‘SwipeCellKit’ (如果很多error用
    pod ‘SwipeCellKit’, :git => ‘https://github.com/SwipeCellKit/SwipeCellKit.git', :branch => ‘develop’)
  2. pod install
  3. import SwipeCellKit
  4. ..省略很多步驟,詳細可以看github中的文件喔

CategoryViewController跟TodoListViewController用SwipeTableViewController應用的完整程式碼:在這

設一個cocoa touch class要讓兩個tableview可以繼承SwipeCellKit

建立一個SwipeTableViewController然後用override的方式去理解subclass

到main.storybord

到CategoryViewController跟TodoListViewController上的Cell
將custom class的class跟module改成上述Swipe

identifier改成Cell,配合SwipeTableViewController中設定的Cell

到CategoryViewController跟TodoListViewController
1.TodoListViewController: SwipeTableViewController

2.cellForRowAt一樣用override讓CategoryViewController跟TodoListViewController分別,像CategoryViewController就是用 “No Categories Added Yet”

3.override一些SwipeTableViewController無法設定的各自屬性,在SwipeTableViewController中無法拿到CategoryViewController跟TodoListViewController的資料,所以用這種方式傳遞資料,再用realm刪除

Chameleon

Lighter and Darker Colors

version1:顏色會都相同CGFloat(indexPath.row/todoItems!.count)

version2:有漸層CGFloat(indexPath.row)/CGFloat(todoItems!.count)

Contrasting Text:讓TEXT根據背景的深淺轉換黑白

讓TodoListViewController的navigationBar搭配parentCategory中的color,還有退出TodoListViewController的navigationBar改回藍色

--

--