У меня есть 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: Если вам нужно больше кода, пожалуйста, спросите!