-
Notifications
You must be signed in to change notification settings - Fork 0
/
UINavigationBar+FlatUI.m
executable file
·40 lines (34 loc) · 1.41 KB
/
UINavigationBar+FlatUI.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//
// UINavigationBar+FlatUI.m
// FlatUI
//
// Created by Jack Flintermann on 5/3/13.
// Copyright (c) 2013 Jack Flintermann. All rights reserved.
//
#import "UINavigationBar+FlatUI.h"
#import "UIImage+FlatUI.h"
@implementation UINavigationBar (FlatUI)
- (void) configureFlatNavigationBarWithColor:(UIColor *)color {
[self setBackgroundImage:[UIImage imageWithColor:color cornerRadius:0]
forBarMetrics:UIBarMetricsDefault & UIBarMetricsLandscapePhone];
NSMutableDictionary *titleTextAttributes = [[self titleTextAttributes] mutableCopy];
if (!titleTextAttributes) {
titleTextAttributes = [NSMutableDictionary dictionary];
}
if (&NSShadowAttributeName != NULL) {
// iOS6 methods
NSShadow *shadow = [[NSShadow alloc] init];
[shadow setShadowOffset:CGSizeZero];
[shadow setShadowColor:[UIColor clearColor]];
[titleTextAttributes setObject:shadow forKey:NSShadowAttributeName];
} else {
// Pre-iOS6 methods
[titleTextAttributes setValue:[UIColor clearColor]forKey:NSShadowAttributeName];
[titleTextAttributes setValue:[NSValue valueWithUIOffset:UIOffsetZero]forKey:NSShadowAttributeName];
}
[self setTitleTextAttributes:titleTextAttributes];
if ([self respondsToSelector:@selector(setShadowImage:)]) {
[self setShadowImage:[UIImage imageWithColor:[UIColor clearColor] cornerRadius:0]];
}
}
@end