开发者

UINavigationBar styling issue?

开发者 https://www.devze.com 2023-03-06 14:06 出处:网络
I have a UINavigationBar I am having style issues. To start out, I use this code (a class inside my navigation controller) to style my UINavigationBar.

I have a UINavigationBar I am having style issues. To start out, I use this code (a class inside my navigation controller) to style my 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.to开发者_开发百科pItem.title;
    self.topItem.titleView = label;

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

@end

@implementation...

Here's my two issues:

  • When I apply this code in another document with different form and styles, it changes everything. Why is this happening?
  • When moving from one view to another, the textColor changes to white. It shows great on start up and when I go back in the navigation controller it works fine.

Thanks in advance!

PS: If you need any more code, please ask!

0

精彩评论

暂无评论...
验证码 换一张
取 消