昨天下载了IOS5 SDK,这个用于将我的UIToolbar背景设置为自定义图像的代码停止工作.如果我将目标设置为IOS4.3及以下,它仍然有效.
[self.bizToolbar insertSubview:[[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"navbar-iphone.png"]] autorelease] atIndex:0];
Run Code Online (Sandbox Code Playgroud)
有人在IOS 5上遇到过这个吗?
小智 49
您可以使用:( [[UIToolBar appearance] setBackgroundImage:toolBarIMG
forBarMetrics:UIBarMetricsDefault];iOS 5中的新功能)
lor*_*isi 35
假设你链接了iOS5 beta SDK,你可以这样做
if([navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)] ) {
//iOS 5 new UINavigationBar custom background
[navigationBar setBackgroundImage:image forBarMetrics: UIBarMetricsDefault];
}
Run Code Online (Sandbox Code Playgroud)
要实现这一点,请看一下iOS 4.3到iOS 5.0 API的差异 并搜索"UINavigationBar.h"
或者仔细看看这里的新方法签名 setBackgroundImage:forBarMetrics:
这里还有UIBarMetrics枚举类型
希望这可以帮助.
Rye*_*AC3 10
这适用于我的工具栏:
//toolBar background image set based on iOS version
[[UIDevice currentDevice] systemVersion];
if ([[[UIDevice currentDevice] systemVersion] floatValue] > 4.9) {
//iOS 5
UIImage *toolBarIMG = [UIImage imageNamed: @"toolBar_brown.png"];
if ([toolBar respondsToSelector:@selector(setBackgroundImage:forToolbarPosition:barMetrics:)]) {
[toolBar setBackgroundImage:toolBarIMG forToolbarPosition:0 barMetrics:0];
}
} else {
//iOS 4
[toolBar insertSubview:[[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"toolBar_brown.png"]] autorelease] atIndex:0];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
34383 次 |
| 最近记录: |