bar button got stick to the y origin as 0 to navigation bar and x as 0.but i want to add some y position to barbutton item.
UIBarButtonItem *barbutton;
barbutton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:self action:@selector(onbackbtnpressed:)];
[barbutton setWidth:30];
[barbutton setTintColor:KANEKA_BLUE_COLOR];
[barbutton setAccessibilityFrame:CGRectMake(10, 10, 30, 20)];
self.navigationItem.leftBarButtonItem = barbutton;
Please tell me how can i set the barbutton frame or how to set the bar button y position.
My views about this question - As per iOS Human Interface Guidelines it is not recommended to add y spacing for the bar button items on navigation bar.
We can update x positioning by setting an array of buttons for navigation item as shown below:
UIBarButtonItem *fixedSpaceBarButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
[fixedSpaceBarButton setWidth:10];
UIBarButtonItem *barbutton;
barbutton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:self action:@selector(onbackbtnpressed:)];
[barbutton setWidth:30];
[barbutton setTintColor:[UIColor redColor]];
[barbutton setAccessibilityFrame:CGRectMake(10, 10, 30, 20)];
self.navigationItem.leftBarButtonItems = [NSArray
arrayWithObjects:fixedSpaceBarButton, barbutton, nil];