Custom background image on UIToolbar in IOS5 SDK

后端 未结 5 515
轮回少年
轮回少年 2020-12-12 22:35

Downloaded IOS5 SDK yesterday, and this code which I use to set my UIToolbar\'s background to a custom image stopped working. If I set the target to IOS4.3 and below it stil

5条回答
  •  情书的邮戳
    2020-12-12 23:10

    Suppose you linked iOS5 beta SDK, you could do something like this

    if([navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)] ) {
            //iOS 5 new UINavigationBar custom background
            [navigationBar setBackgroundImage:image forBarMetrics: UIBarMetricsDefault];
    } 
    

    To realize this, take a look at here iOS 4.3 to iOS 5.0 API Differences and search for "UINavigationBar.h"

    or take a close look at the new method signature here setBackgroundImage:forBarMetrics:

    Also here is the UIBarMetrics enum type

    Hope this helps.

提交回复
热议问题