Placing a custom view based UIBarButtonItem in the navigation bar without default horizontal padding?

I have tried this and it works: 1) Create a custom UIToolbar subclass, which does nothing in -drawRect:, and is not opaque, and has backgroundColor = UIColor clearColor. 2) Create a custom UIBarButtonItem with the toolbar as the custom view. 3) Add your buttons to the custom toolbar.4) In your custom toolbar override -layoutSubviews and do your own spacing.

Another trick is that you can simply make the navigation bar somehow wider than the viewport, so the right padding is clipped off, and your button appears at the right place! This only works if you manage the UINavigationBar directly, i.e. Not thru a navigation controller.

– Evadne Wu Mar 3 at 19:11 Thanks Evadne. I moved past this with a workaround, but I'll try to come back to this post release to confirm the suggested workaround you have so I can then mark it as the accepted answer. – idStar Mar 4 at 12:31 I did find a cleaner implementation, possible with iOS5.

See the answer here: stackoverflow. Com/questions/6021138/… I tested this solution and it worked. Two lines of code and the least intrusive.

– idStar Nov 9 at 18:48.

55As commented above, the solution I went with is based on this answer to a different, but very much related question: How to adjust UIToolBar left and right padding. It is also facilitated by (and depends on) iOS5, which allows you to set multiple buttons on the left or right side, instead of just one. Here's an example of removing the padding to the left of a custom left button item: UIBarButtonItem *backButtonItem // Assume this exists, filled with our custom view // Create a negative spacer to go to the left of our custom back button, // and pull it right to the edge: UIBarButtonItem *negativeSpacer = UIBarButtonItem alloc initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil; negativeSpacer.

Width = -5; // Note: We use 5 above because that's how many pixels of padding iOS seems to add // Add the two buttons together on the left: self.navigationItem. LeftBarButtonItems = NSArray arrayWithObjects:negativeSpacer, backButtonItem, nil; And with this, the left padding for the left bar button item in a navigation bar, is gone!

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions