【问题标题】:didn't work in ios4 UIToolBar在 ios4 UIToolBar 中不起作用
【发布时间】:2012-03-19 10:47:35
【问题描述】:

我在导航控制器中使用了 UIToolBar。我已经使用下面的代码设置了 UIToolbar 的背景图片

if ([[[UIDevice currentDevice] systemVersion] floatValue] > 4.9) {
                NSLog(@"IOS 5555555");
        //iOS 5
        if ([tools respondsToSelector:@selector(setBackgroundImage:forToolbarPosition:barMetrics:)]) { 
            [tools setBackgroundImage:[UIImage imageNamed:@"toolbar.png"] forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];
        }

    } else {
        //iOS 4
        NSLog(@"IOS 4444444");
        [tools insertSubview:[[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"toolbar.png"]] autorelease] atIndex:0]; 
    }

对于 ios5 它工作正常,但是当我在 iOS 4 中运行我的应用程序时,它设置了工具栏的默认值。基本上我需要设置 UIToolBar 的背景图像。

【问题讨论】:

    标签: objective-c xcode ios5 ios4


    【解决方案1】:

    我建议你为 iOs 4 继承 UIToolbar 并覆盖 drawRect 方法

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多