UINavigationBar - change UIBarButtonItem positions
ios, objective-c, uitoolbaritem
Solution
I dont think you have the ability to move a `UIBarButtonItem` but you might be able to achieve the same effect by adding that `UIView` element as a subview to the navigationBar (or `navItem`). You'll need to play with it a bit. It should allow for much more flexibility.
hope this helps.
Problem
I am using a UINavigationController and its bar within my app. Now I want to change the leftBarButtonItem and rightBarButtonItem positions. I want them to be on a different x and y position having a custom witdth and height. But the problem is, that changing the frame does not change anything with the barButtonItem. I do not now why, but the frame always gets resetted to its original coordinates. Here is my code which I call in viewWillAppear: ``` UINavigationItem *navItem = [[self.navigationBar items] lastObject]; UIView *rightview = [[UIView alloc] initWithFrame:CGRectMake(0,0,66,30)]; rightview.backgroundColor = [UIColor blueColor]; //add custom view UIBarButtonItem *search = [[UIBarButtonItem alloc] initWithCustomView:rightview]; navItem.leftBarButtonItem = search; ``` The view is not starting at 0/0, the x position for example is at 5px insetead of 0. Any suggestions on how to solve this issue?