Pavel Zdenek
Pavel Zdenek

Reputation: 7293

UIToolbar appearance interface for top/bottom position

I've got two UIToolbars in the view, on the top and on the bottom. And i'm trying to apply appearance consistently across iOS versions. There is this setBackgroundImage: forToolbarPosition: since iOS5, which names the parameter topOrBottom. But the parameter type UIBarPosition is an enum with definitely more than two options (which is what Or suggests IMO) and moreover declares existence only since iOS7 (and online Apple doc confirms it).

The observed effect is that the images are applied per position only on iOS7. On iOS6 the image is applied to both positions regardless of the position parameter. Which is not really a surprise, because UIBarPositioningDelegate isn't called on iOS<7 so it doesn't understand what i meant by setting the toolbar frame to certain values. But the parameter toolbarPosition exists since iOS5, so the question is: how do i use the parameter on iOS<7? Is it supposed to be useable through UIAppearance?

Upvotes: 2

Views: 835

Answers (1)

random
random

Reputation: 8608

I am able to reproduce this error in XCode 4.6.3 as well. I believe this to be either a bug or wrong documentation. In Xcode 4.6.3, here is the documentation for UIToolbarPosition which was later changed to UIBarPosition.

UIToolbarPositionAny
Indicates the toolbar may be in any position.
Available in iOS 5.0 and later.
Declared in UIToolbar.h.

UIToolbarPositionBottom
Indicates the toolbar is at the **top** of its containing view.
Available in iOS 5.0 and later.
Declared in UIToolbar.h.

UIToolbarPositionTop
Indicates the toolbar is at the **bottom** of its containing view.
Available in iOS 5.0 and later.
Declared in UIToolbar.h.

As you can see the documentation here even seems to be wrong. So I believe either we have a misunderstanding of what UIToolbarPosition and UIBarPosition mean (they may only refer to shadows which is unlikely but possible), or it's a bug. imo.

EDIT:

typedef enum {
   UIToolbarPositionAny = 0,
   UIToolbarPositionBottom = 1,
   UIToolbarPositionTop = 2,
} UIToolbarPosition;

Upvotes: 1

Related Questions