-1

I'm using setBackgroundImage:forToolbarPosition:metrics: method of UIToolbar. That's my code:

toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0,0, 320, 44)];
[toolbar setBackgroundImage:[UIImage imageNamed:@"top"] forToolbarPosition:UIToolbarPositionTop barMetrics:UIBarMetricsDefault];
[toolbar setBackgroundImage:[UIImage imageNamed:@"bottom"] forToolbarPosition:UIToolbarPositionBottom barMetrics:UIBarMetricsDefault];
[self.view addSubview:toolbar];

As you can see I've put my toolbar on top. However when I run the code the toolbar image used is [UIImage imageNamed:@"bottom"].

How UIToolbarPosition is obtained? My first idea is frame check ( < 1/2 superview frame is top, otherwise is bottom... or sort of).

It still on bottom. Any idea?

danielemm
  • 1,636
  • 1
  • 14
  • 24

1 Answers1

1

on iPhone UIToolbarPosition is always on bottom because UIToolbar is not supposed to be on top.

on iPad it works fine, UIToolbarPositionTop is used when toolbar.frame.origin.y = 0, UIToolbarPositionBottom otherwise.

danielemm
  • 1,636
  • 1
  • 14
  • 24