Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.1 kB
1
Indexable
Never
import UIKit
import WebKit

class ViewController: UIViewController, WKNavigationDelegate {

    private var webView: WKWebView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // WebView oluşturma
        webView = WKWebView(frame: .zero)
        webView.navigationDelegate = self
        view.addSubview(webView)
        
        // Otomatik boyutlandırma ve kenarlıkların eşleştirilmesi
        webView.translatesAutoresizingMaskIntoConstraints = false
        webView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
        webView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
        webView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
        webView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
        
        loadWebsite()
    }
    
    func loadWebsite() {
        if let url = URL(string: "https://infaz.com.tr") {
            let request = URLRequest(url: url)
            webView.load(request)
        }
    }
}