SWIFT

WKWebView Reload Code

HiroDaegu 2023. 3. 4. 22:50
728x90
SMALL
webView.scrollView.refreshControl = UIRefreshControl()
webView.scrollView.refreshControl?.addTarget(self, action: #selector(handleRefreshControl), for: .valueChanged)
webView.scrollView.refreshControl?.tintColor = UIColor(red: 187 / 255, green: 38 / 255, blue: 73 / 255, alpha: 1.0)
webView.scrollView.refreshControl?.attributedTitle = NSAttributedString(string: "당겨서 새로고침", attributes: [.foregroundColor: UIColor(red: 187 / 255, green: 38 / 255, blue: 73 / 255, alpha: 1.0)])

...

@objc func handleRefreshControl() {
    DispatchQueue.main.asyncAfter(deadline: .now() + 0.7) {
        self.webView.reload()
        self.webView.scrollView.refreshControl?.endRefreshing() 
    }
}

...
728x90
LIST