0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

tableView Cell 右にスライドさせてボタンなどを表示

Posted at

今回の内容

82068F31-ECB3-4B5C-9EF2-74611AA582F3_1_201_a.jpeg

コードと簡単解説

  • 右スライドでボタンを表示させる場合はfunc tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {}を使用します。
    func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
        
        let rightSlideMoves = { () -> [UIContextualAction] in
            
            let slideActionArray = [UIContextualAction(style: .normal, title: "01", handler: { _, _, _ in
                                    print("右のボタン01が押されました")}),
                                    UIContextualAction(style: .normal, title: "02", handler: { _, _, _ in
                                    print("右のボタン02が押されました")})]
            
            return slideActionArray
        }()
        
        rightSlideMoves[0].backgroundColor = .systemIndigo
        rightSlideMoves[1].backgroundColor = .systemBlue
        
        return UISwipeActionsConfiguration(actions: rightSlideMoves)
    }

終わり

ご指摘、ご質問などありましたら、コメントまでお願い致します。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?