27 марта 2024
Нет комментариев
self.progressbar.trackTintColor = .white self.progressbar.progressTintColor = UIColor(red:244/255.0, green: 66/255.0, blue: 8/255.0, alpha: 1)
self.progressbar.trackTintColor = .white self.progressbar.progressTintColor = UIColor(red:244/255.0, green: 66/255.0, blue: 8/255.0, alpha: 1)
func share(message: String, link: String){ if let link = NSURL(string: link){ let objectsToShare = [message, link] as [Any] let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil) self.present(activityVC, animated: true, completion: nil) } } share(message: "test", link: "https://ya.ru/")
https://stackoverflow.com/questions/37938722/how-to-implement-share-button-in-swift
if(string.contains("?share")){ let urlArr = string.components(separatedBy: "?") let link = urlArr[0] }
ios webview pull to refresh
override func viewDidLoad() { // after webView.load let refreshControl = UIRefreshControl() refreshControl.addTarget(self, action: #selector(reloadWebView(_:)), for: .valueChanged) webView.scrollView.addSubview(refreshControl) } @objc func reloadWebView(_ sender: UIRefreshControl){ webView.reload() sender.endRefreshing() }
import UIKit import WebKit class ViewController: UIViewController, WKNavigationDelegate { var webView: WKWebView! override func loadView() { webView = WKWebView() webView.navigationDelegate = self view = webView } override func viewDidLoad() { super.viewDidLoad() let url = URL(string: "http://example.com")! webView.load(URLRequest(url: url)) let refresh = UIBarButtonItem(barButtonSystemItem: .refresh, target: webView, action: #selector(webView.reload)) toolbarItems = [refresh] navigationController?.isToolbarHidden = false } func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!){ title = webView.title } }
https://www.ioscreator.com/tutorials/webview-ios-tutorial-ios11