UIAppearence Support for IOS 6 - unexpected results
Asked Answered
S

1

6

Below code is perfectly working fine iOS 5, but not on iOS 6 or above. What I want that for Email composer sheet the navigationBar image will be different then other UINavigationBar classes. I can't understand that debug pointer is responding the appearance method but on device it shows navigationBar image as "bgNavigationBar.png"; expected is "bgNavigationBar_2.png".

Please guide me.......

if ([[UINavigationBar class]respondsToSelector:@selector(appearance)]) {
    UIImage *logoImage44 = [[UIImage imageNamed:@"bgNavigationBar.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
    [[UINavigationBar appearance] setBackgroundImage:logoImage44 forBarMetrics:UIBarMetricsDefault];

    UIImage *ImagePlain = [[UIImage imageNamed:@"bgNavigationBar_2.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
    [[UINavigationBar appearanceWhenContainedIn:[MFMailComposeViewController class], nil] setBackgroundImage:ImagePlain forBarMetrics:UIBarMetricsDefault];
}
Strep answered 2/1, 2013 at 16:17 Comment(1)
iOS 6 bug. Open Radar - openradar.me/radar?id=2984402Jankell
S
7

This thing is not working in ios6.

[[UINavigationBar appearanceWhenContainedIn:[MFMessageComposeViewController class], nil] setBackgroundImage:[UIImage imageNamed:@"bgNavigationBar_2.png"] forBarMetrics:UIBarMetricsDefault];

Just you need to set this property in your Mail Handler Class.

if (![[UINavigationBar class]respondsToSelector:@selector(appearance)])
{
    UIView *backgroundView = [[[UIView alloc] initWithFrame:CGRectMake(0,0,320,44)]autorelease];

    [backgroundView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"bgNavigationBar_2.png"]]];
    controller.topViewController.navigationItem.titleView = backgroundView ;
}
else
{
    UIImage *gradientImagePlain = [[UIImage imageNamed:@"bgNavigationBar_2.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
    [[UINavigationBar appearance] setBackgroundImage:gradientImagePlain forBarMetrics:UIBarMetricsDefault];
}

and then reset another image for all other navigation controller's background image.

- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
    [self.parentController dismissModalViewControllerAnimated:YES];
    UIImage *gradientImagePlain = [[UIImage imageNamed:@"bgNavigationBar.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
    [[UINavigationBar appearance] setBackgroundImage:gradientImagePlain forBarMetrics:UIBarMetricsDefault];
}

Hope this will work for you.

Sanhedrin answered 15/1, 2013 at 15:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.