Trying to create an iOS WKWebView with a size smaller than the screen programmatically

Your problem is that UIViewControllers presented in certain ways will manage the frame of their view. If you present it modally, as the root controller, or in a navigation bar, for example, setting the fame manually won't have an effect. (Those are only a few examples).

If you want to manage the frame of the view, you can add the webView as a subview to your view controller's view. Modifying it's frame will work then.

One thing I'd like to point out is that calling self.view.frame = webView.frame after calling self.view = webView is redundant, because they are both the same object, so what you are effectively doing is:

self.view.frame = self.view.frame