关于定制的UINavigationBar

时间:2011-12-29 05:42:49

标签: ios uinavigationcontroller ios5 uinavigationbar customization

我正在为ipad制作应用程序。有一些麻烦。

我使用包含UINavigationViewController的PopoverView。

首先,当我点击时,我的PopoverView看起来像下面的图片。 我可以清楚地看到navigationBar背景图片的边框。

enter image description here

如果再次单击[Genese 1]按钮,将再次出现PopOverView。 它没有看到navigationBar的背景图像的边框。

enter image description here

请告诉我我的错误。谢谢 !!!

AppDelegate.m

    // Create resizable images  
    UIImage *gradientImage44 = [[UIImage imageNamed: @"surf_gradient_textured_44.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];

    // Set the background image for *all* UINavigationBars
    [[UINavigationBar appearance] setBackgroundImage:gradientImage44 forBarMetrics:UIBarMetricsDefault];

    // Customize the title text for *all* UINavigationBars
    [[UINavigationBar appearance] setTitleTextAttributes:
     [NSDictionary dictionaryWithObjectsAndKeys:
      [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0], 
      UITextAttributeTextColor, 
      [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8], 
      UITextAttributeTextShadowColor, 
      [NSValue valueWithUIOffset:UIOffsetMake(0, -1)], 
      UITextAttributeTextShadowOffset, 
      [UIFont fontWithName:@"Arial-Bold" size:0.0], 
      UITextAttributeFont, 
      nil]];

    // Customize UIBarButtonItems 
    UIImage *button30 = [[UIImage imageNamed:@"button_back_textured_30.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)];


    [[UIBarButtonItem appearance] setBackgroundImage:button30 forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];

    [[UIBarButtonItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:0.5], UITextAttributeTextColor, [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0], UITextAttributeTextShadowColor, [NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowOffset, [UIFont fontWithName:nil size:0.0], UITextAttributeFont, nil] forState:UIControlStateNormal];

ViewController.m

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.layer.cornerRadius = 0.0f; // I don't want corner's round edges.

    self.backView.layer.cornerRadius = 5.0f;
    self.backView.layer.borderWidth = 1;
    self.backView.layer.borderColor = [UIColor colorWithRed:0/255.0f green:0/255.0f blue:0/255.0f alpha:1].CGColor; 
    [self.navigationController setNavigationBarHidden:NO];

}

//when call again this view 
-(void)viewDidAppear:(BOOL)animated {

    self.view.layer.cornerRadius = 0.0f; 

    [super viewDidAppear:animated];
}

0 个答案:

没有答案