Preview:
    func createBackButton() {
        let image = UIImage(named: "left-arrow") as UIImage?
        let button = UIButton(type: UIButton.ButtonType.custom) as UIButton
        let screenSize: CGRect = UIScreen.main.bounds
            let screenWidth = screenSize.width
            let screenHeight = screenSize.height
        
        button.frame = CGRect(x: screenWidth * 0.05, y: screenHeight * 0.05, width: screenWidth * 0.05, height: screenWidth * 0.03) // (X, Y, Height, Width)
        button.setImage(image, for: .normal)
        button.addTarget(self, action: #selector(customGoBack(sender:)), for: UIControl.Event.touchUpInside)
            self.view.addSubview(button)
    }
    
    @objc func customGoBack(sender: UIButton) {
        if self.webView.canGoBack {
            print("Can go back")
            self.webView.goBack()
            self.webView.reload()
        } else {
            print("Can't go back")
        }
    }
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter