UIRefreshControl

윤주현·2023년 7월 4일

UIKit

목록 보기
2/9

UIRefreshControl

화면 맨 위에서 밑으로 끌어당기면 새로고침 하는 기능(scrollable view에서만 사용 가능)

func configureRefreshControl () {
   // Add the refresh control to your UIScrollView object.
   myScrollingView.refreshControl = UIRefreshControl()
   myScrollingView.refreshControl?.addTarget(self, action:
                                      #selector(handleRefreshControl),
                                      for: .valueChanged)
}
    
@objc func handleRefreshControl() {
   // Update your content…


   // Dismiss the refresh control.
   DispatchQueue.main.async {
      self.myScrollingView.refreshControl?.endRefreshing()
   }
}

UITableView에서는 기본적으로 refreshControl이라는 프로퍼티가 존재하니까 UIRefreshControl 인스턴스 할당해서 사용하면 된다.

0개의 댓글