Prevent Tab Bar from cutting off WKWebView text - ios

Our UITabBar is cutting off the bottom of our WKWebView text.
Our Storyboard view has a few labels at the top of the screen and a WKWebView set below those labels programatically. It works great but you can't scroll to the end of the WKWebView to see the last line of the text.
I believe this doesn't happen with UIWebView but that API is deprecated.
I understood automaticallyAdjustsScrollViewInsets to be the solution but apparently that doesn't work in this case.
Have tried setting Extend Edges \ Under Bottom Bars to false on the Storyboard. This comes close to solving the issue - the scrolling issue is resolved. Only issue is the Tab Bar then changes color to a darker color and I can't seem to get that to revert to the default lighter grey metallic color.
What is the correct way to do this?

WKWebView contains UIScrollView. UIScollView has contentInset property.
https://developer.apple.com/reference/uikit/uiscrollview/1619406-contentinset
Use this property to add to the scrolling area around the content. The unit of size is points. The default value is UIEdgeInsetsZero.

Figured it out based on some other SO posts:
webView.scrollView.contentInset = UIEdgeInsetsMake(0.0, 0.0, controller.tabBarController!.tabBar.frame.height, 0.0)
... maybe there is a better way (?) but this worked.

Related

How to position the NavigationBar x pixels from the top

I want to position the UINavigationBar x pixels from the top. Is this possible? Here is a screenshot of the desired result.
To clarify, I want the NavigationBar to be positioned in the orange area. The area black area above is an ARKit view running and should not be covered by anything.
Is this even possible?
I've tried setting the NavigationBar frame and messing around with the positionForBar property. Nothing have an effect, the NavigationBar is always rendered at the top. One thing that add is that this solution, if there is any, has to be done in code and not in storyboard.
Just create a constraint from the Top Safe Area Guide's bottom to your view...?
Unfortunately, You have said it, you changed the frame but nothing happened as you don't have the ability to change(Move or resize) the UINavigationController's navigation bar. To solve this problem you have to write your own view controller class.
Try setting the navigation bar’s transform.
i.e.
navigationController?.navigationBar.transform = CGAffineTransform(translationX: 0, y: yourTopInset)

Wrong position of text in search bar

When I tap to search bar in navigation bar title,text of textfield changing position to bottom and placeholder have alignment center. How fix it? Need native vertical center position text and placeholder of search bar.
The problem you are having could be caused by numerous errors.
1)
Scroll View insets in layout is not checked.
2) If constraints are added, they could be affecting the searchTextView insets also. Remove some and check if they are a factor.
3) You have forgotten to adjust the search text offset.
Thx all for answer, I solved this issue. In my case, need uncheck in storyboard Extended Edges - Under Top Bars. And I use custom views in storyboard scenes. I enable opaque navigation bars in storyboard scene and my custom view(nib file) and it work! Thx all for answers,again)

StatusBar tint and hidebaronswipe

I just want to change the color of my statusBar to follow the color of my navigationController.
I've read some posts, and now I'm understand that I'm not able to change the statusBar color, basically, I need have a view behind and change the color of that view. Ok.
So my problem is:
I have a UITableView inside a ViewController and this ViewController is embed in a NavigationController.
In the NavigationController I set the flag Hide Bars:On Swipe
When I swipe the TableView my navigationBar disappear, but it also override my view that I set to a height of 20 to simulate the StatusBar.
I found this Post, and it is the exactly my problem, I've read on this post a logical solution, but OP don't answered if it worked or not, anyway, I think that I need to work correctly with the constraints, but this solution doesnt work for me on xcode7 swift 2.0.
Any ideas?
I fount the perfectly solution on this post:
The solution marked as accepted is outdated.
Autolayout: Add constraint to superview and not Top Layout Guide?

UIToolbarPosition set to bottom on resize

I have a UIToolBar at the top of one of my views and the shadowing shows up on the bottom of the tool bar as I'd expect. I know UIToolbarPosition is internally set to UIToolbarPositionTop.
When I rotate my device (iPad), the tool bar grows (using auto sizing in IB) and the UIToolbarPosition changes to UIToolbarPositionBottom which flips the shadow to be at the top of the bar. If I don't have the bar resize, it remains correct, but of course doesn't stretch to match screen width.
So, what gives? What would cause the UIToolbarPosition to flip on me? This is sitting at 0,0 the whole time and only changes width based on rotation.
Extra: I've considered work arounds like using a UINavigationBar. UIAppearance is probably a no go because I do have a toolbar at the bottom too and I do want my "top" different than my "bottom"
I eventually solved this using the UIBarPositioning protocol on UIToolBarand setting the barPosition = UIBarPositionTop

How do I mimic the background color of this table view?

Apple ships an app named “Contacts” on every iOS device. On the iPhone and iPod touch, it has a very particular way of styling the area above the search bar:
How is this coloring accomplished? Specifically, how is the color only visible at the top of the table view, and not at the bottom? Setting the backgroundColor property of the table view or its backgroundView does not achieve the desired result, either.
I would just create a UIView with gray backgroundColor containing a UISearchBar at the bottom of it, and set that to the tableHeaderView of your UITableView.
Maybe it's another view in a UIScrollView? (If so, above contentOffset.)

Resources