fjcaetano / ReCaptcha

[In]visible ReCaptcha v2 for iOS
http://blog.flaviocaetano.com/post/recaptcha-reaches-1-dot-0/
MIT License
267 stars 133 forks source link

Is there any way to center CAPTCHA widget on the screen? #100

Closed DarkSatyr closed 3 years ago

DarkSatyr commented 3 years ago

iOS 13.4 Device: iPhone X

Captcha widget appears on the upper-left side of screen IMG_0006 1

DarkSatyr commented 3 years ago

Found a solution: Since captcha has fixed size... let width = min(302, viewController.view.bounds.width) let height = min(516, viewController.view.bounds.height) webView.frame = CGRect(center: viewController.view.bounds.center, size: CGSize(width: width, height: height))

Inside configureWebView closure

vassily-fr commented 3 years ago

Found a solution: Since captcha has fixed size... let width = min(302, viewController.view.bounds.width) let height = min(516, viewController.view.bounds.height) webView.frame = CGRect(center: viewController.view.bounds.center, size: CGSize(width: width, height: height))

Inside configureWebView closure

But what if google choose to change size one day ? Is there a another way to performe the "center"

fjcaetano commented 3 years ago

Webviews usually have a hard time figuring out the size of their contents. You can try and set the frame based on the contentSize, but your best bet would be to use a fixed size