Left UIBarButton Item has extra padding to its right - ios7

I have a custom UIBarButtonItem that uses an image. There seems to be a lot of extra padding around the button (10 px + I believe). I've seen solutions of how to remove the padding to the left, but my issue is that there is padding to the right.
My buttons image is only 44x44 but I believe the tappable space in iOS7 is more like 44-50 x ~80.
How can remove this space? I can't set a negative space (e.g - 10) to the right of my image because I believe that will be added after my buttons padding.

Related

UIButton width doesn't increase based on text if insets are given

I have given trailing, top and height constraints to the button.
As you can see in the attached screenshot, if I remove all the insets given, then button looks perfect and button fits based on text length.
But I want to give right-left title insets as well as left image inset.
Then button is not displaying text properly as shown in the attached screenshot.
Auto-layout can be a little tricky when adjusting the Title Label of a UIButton.
From Apple's docs for titleEdgeInsets:
This property is used only for positioning the title during layout. The button does not use this property to determine intrinsicContentSize and sizeThatFits(_:).
You have a couple options...
One is to subclass UIButton and override .intrinsicContentSize.
Another option, which may be better for your case, is to adjust the Content Insets instead of the Title Insets.
As you described, this button has Top / Trailing / Height constraints:
Note that the Left value for the Image Inset is a negative value. You may / probably will want to tweak the values I used.

Autolayout form login in Xcode 8

I have a problem in managing the autolayout of a form of login with these elements
Form login
The elements are an ImageView on the top, two textFields and two buttons in the middle and another button on the bottom.
Does anyone have any advice?
Connect username field to be centered horizontal in container and vertical space between UIImage and leading ,trailing constraints to the view(left and right ,give value to look similar like in photo if you dont have strict size) after just connect all other fields with username field to be equal width and height ,centered horizontal and vertical space between them.Try to make vertical space like in image ,play litle bit try diferent values that match like in form on photo.
"Continue without registration" set center horizontaly and vertical space to bottom layout (vertical space = 16 ,for example)

UIToolbar not resizing when rotating with autolayout, with UIBarButtonItems misplaced

it's the first time I'm seriously using autolayout so I'm sure I'm missing something obvious.
I have a very simple view embedded in a UINavigationController. There are three subviews: a UIWebView, a UIToolbar (which in turn contains three UIBarButtons) and a UIActivityIndicatorView. It's just a basic browser view, basically.
I managed to have everything appear as it should even on rotation, except for the toolbar: if the view is first loaded in vertical orientation, going landscape will not resize the toolbar from 44 to 32 points. Originally, before I wiped everything out, it did resize the toolbar BUT the built-in UIBarButtonItems appeared lower and cut off, as if the toolbar was still 44 points tall but pushed 16 points out of the screen.
If the view is first loaded horizonttaly, the bar is 32 points high but the built-in UIBarButtonItems appear still like that, and rotating to vertical will keep it at 32 points.
I honestly have no idea how to make this work as expected (ie. resize properly when rotated, with the buttons showing properly!), so if anyone could point me in the right direction -- pun intended -- I would be really grateful.
The activity indicator is right in the middle of the frame, with these constraints:
Align Center X to Superview
Align Center Y to Superview
The web view is set to use all available space from the top of the view (including the navbar) up to the top of the toolbar, and has these contraints:
Top Space to Superview
Bottom Space to Toolbar
Align Trailing to Toolbar
Bottom Space to Toolbar (it's actually listed twice)
Align Leading to Toolbar
The toolbar is a mess. It has:
Bottom space to Superview
Align Center X to Superview
Top Space to Web View
Align Trailing to Web View
Top Space to Web View (listed twice)
Leading Space to Superview
Align Leading to Web View
Bottom Space to Bottom Layout Guide
The problem is that by not adding any constraints at all, the web view is much bigger than it should be, and the toolbar doesn't even show.
I mostly set these constraints using the horizontal and vertical red bars (similar to springs and strouts) in the 'pin' popover for autolayout, but I'm starting to think that's not the most appropriate approach.
Note that I'm not trying to use autolayout within the toolbar, I read that it wouldn't work and I'm just using the built-in buttons plus a couple of labelled ones (those 'arrows' are really unicode characters, I may change them to prettier images at some point.)
Thank you in advance. :-)

How to create labels with dynamic size in iOS 6 with autolayout

I'm having trouble with autolayout and labels that get their text set in the source code based on some external conditions. These layouts (portrait and landscape) look like this on the simulator:
http://imgur.com/l6Iirun
http://imgur.com/n7RwwSD
The second one is obviously not what I want it to be, the label with the URN should fill the whole screen.
I have a width constraint for the dynamic label added by Xcode which I can't get rid of even though the "Name"-label has a fixed width and all horizontal spaces are fixed as well which should logically rid me of the need to have a width constraint for the label containing the dynamic text.
Any help on how to achieve what I want? Thanks in advance!
It looks to me like your labels are not binding their trailing edge to the superview. In the lower right there is the little 'I beam' icon, click on your label and then that icon, the top of the menu should be 'Pin' and pick trailing edge to superview. The label should expand to fit the width of the screen, minus some padding. Once that is in place you should be able to remove the width constraint - although you may need to find it in the size inspector and select promote to user constraint before you can remove it.
If you don't see the pin menu, try going up to the top and picking Editor -> Pin and you should see it there.
If it is already pinned, try increasing the content compression resistance priority and decreasing the priority of the width - although if pinning it does not fix it then there is another constraint at play.

UITextView reporting incorrect height

I have a UITextView with a width of 240. Monitoring the text width shows that it is wrapping the text when the text width >= 224.
In this situation, where the UITextView wraps the text onto the next line, but the length of the text is not greater than 240, the text height is being reported as if it was a single line of text, rather than the height of two lines (since the UITextView wrapped it).
Any ideas why this is happening and how i can resolve it?
UITextView is a subclass of UIScrollView and there are some default insets applied—8 pixels on both the left and right side. I have never managed to find a way to get rid of them.