UINavigationBar样式问题?

时间:2011-05-16 22:31:12

标签: objective-c uinavigationcontroller uinavigationbar

我有一个UINavigationBar我有风格问题。首先,我使用此代码(导航控制器中的一个类)来设置UINavigationBar的样式。

#import...

@implementation UINavigationBar (UINavigationBarCustomDraw)

- (void) drawRect:(CGRect)rect {

[self setTintColor:[UIColor colorWithRed:0.9f green: 0.9f blue:0.9f alpha:1]];

if ([self.topItem.title length] > 0 && ![self.topItem.title isEqualToString:@"Back to ..."]) {
    [[UIImage imageNamed:@"UINavigationBar_background.png"] drawInRect:rect];

    CGRect frame = CGRectMake(0, 0, 320, 44);
    UILabel *label = [[[UILabel alloc] initWithFrame:frame] autorelease];
    [label setBackgroundColor:[UIColor clearColor]];
    label.font = [UIFont boldSystemFontOfSize: 20.0];
    label.shadowColor = [UIColor clearColor];
    label.textAlignment = UITextAlignmentCenter;
    label.textColor = [UIColor colorWithRed:(70.0 / 255.0) green:(70.0 / 255.0) blue:(70.0 / 255.0) alpha: 1];
    label.text = self.topItem.title;
    self.topItem.titleView = label;

} else {
    //[[UIImage imageNamed:@"login_button.png"] drawInRect:rect];
    self.topItem.titleView = [[[UIView alloc] init] autorelease];
}
}

@end

@implementation...

这是我的两个问题:

  • 当我将此代码应用于具有不同形式和样式的其他文档时,它会更改所有内容。为什么会这样?
  • 从一个视图移动到另一个视图时,textColor变为白色。它在启动时表现很好,当我回到导航控制器时它工作正常。

提前致谢!

PS:如果您需要更多代码,请询问!

0 个答案:

没有答案
相关问题