【发布时间】:2019-03-02 13:03:05
【问题描述】:
我正在为自己制作一个待办事项应用程序,并且我想制作一个功能来将待办事项标记为已完成。它添加了一个复选标记,字体应该变成灰色,但我是编码新手,所以我真的不知道如何将字体颜色和复选标记保存到内存中。我不知道我是否应该将它保存到 userdefaults 或核心数据,最重要的是如何保存它。非常感谢任何帮助。
代码如下: 我想保存 textColor 和 accesoryType
func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
let done = UIContextualAction(style: .normal, title: "Done") { (action, view, nil) in
print("Done")
tableView.cellForRow(at: indexPath)?.textLabel?.textColor = UIColor.lightGray
tableView.cellForRow(at: indexPath)?.accessoryType = .checkmark
}
done.backgroundColor = .blue
let config = UISwipeActionsConfiguration(actions: [done])
config.performsFirstActionWithFullSwipe = false
return config
}
【问题讨论】:
标签: swift xcode uitableview core-data nsuserdefaults