Wrong position of text in search bar - ios

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)

Related

UIView overlapping with tab bar elements iOS

I made a view for a switch view. Now I already had tabbed menu buttons in it. The problem is the subview for the switch view seems to be overlapping with the tab bar icons at the bottom. Please help.
i think thats because your tabBar is set to translucent. set it to non-translucent from storyboard or programatically.
self.tabBarController.tabBar.translucent = false
You should have a constraint that sets the vertical space between your subview and your tabbar.
Also, check that your layout respects the iPhone X Safe Area (https://developer.apple.com/ios/human-interface-guidelines/overview/iphone-x/), from your image it seems that your elements overlap the safe area at the bottom.

TopLayoutGuide spacing set to 0 creates empty space

I am creating UI in xcode. I have added imageView which topLayoutGuide vertical spacing is set to 0. So I think that it should be positioned right under status bar. However it is positioned under navigation bar (which is not even present).
In the same storyboard I have some views that are embed in navigation controller and it is set to transculent=NO. But this view isnt even linked to them. So I dont think that this should be a problem.
Any ideas how to fix this?
Thanks in advance

UIView Under Nav and Tab Bars

Using storyboard and Swift, I have a view controller which has two elements on it. A UITextField, and a UIView, which I use merely to give a colored border to the UITextField. The UITextField is a child of the UIView. See:
The problem I am having is that despite having set the top bar and bottom bar simulated metrics attributes to Opaque Navigation Bar and Opaque Tab Bar respectively, See:
When the app builds and runs the top of the UIView is always underneath the nav bar. My over all feeling is that this is somehow a constraints issue but I have not been able to find the solution to it. How do I set the constraints so that the UIView is always immediately underneath the nav bar, and the bottom of the view is always just on top of the tab bar?
Select your UIView in storyboard and assign constraints to the top margins and to bottom margins. There is a 'Pin' button you use to do this that looks something like a Tie-Fighter ship in Star Wars, it is located at the bottom right of your storyboard view.
This will set margins to stretch to top and bottom always.
That is what the layout guides are for. Pin the top to the Top Layout Guide and the bottom to the Bottom Layout Guide. The guides will always move to adjust for any top and bottom bars.

iOS/Swift: Dynamically Resize a Toolbar

I'm trying to make an app with a toolbar that can be resized. Basically, the toolbar can alternate between being at the bottom of the view and being at the top. When a button is pressed, it switches from one to the other. The problem is that when it is at the top, I want the size of the toolbar to expand to accommodate the status bar, but I don't know how to do this.
I've seen some solutions for changing the toolbar size but they all seem static and not something that can be changed with the tap of a button. Any suggestions on how to do this? Perhaps a different solution altogether?
You can use a normal UIView and customize it so it looks like a UIToolbar, then just set constraints using AutoLayout and animate the height-constraint.

How to make a UITableViewController subclass respect topLayoutGuide in iOS7?

in my app I have a simple UITableViewController that's just plain Objective-C code, no .xib or storyboard involved. It represents the contents of one tab in a tab bar.
Since iOS 7 its contents are overlapped by the status bar at the top and tab bar at the bottom.
Using only code, how can I make the table view add space at the top and bottom to align with topLayoutGuide and bottomLayoutGuide?
I know about
self.edgesForExtendedLayout=UIRectEdgeNone;
but that seems to simply shrink the table view to not intersect the tab bar and to disable the transparency of the tab bar. Instead I'd like the table view to add some padding.
Thanks!
Update:
I've also tried explicitly setting automaticallyAdjustsScrollViewInsets to YES, but that didn't help either (should be the default behavior anyway).
It seems this is not (yet) supported, at least for programmatically created UITableViewControllers without an UINavigationController that's embedding them.
I checked the position for both layout guides, and at run-time both off-sets read 0 distance from the edges of the screen. Hence automaticallyAdjustsScrollViewInsets won't set the insets correctly.
So now I actually modify my first section header and last section footer manually to add 21 pixels at the top and 50 pixels at the bottom respectively.
Bummer. :-(

Resources