[IOS Weibo project, [iOS blog Project
A. Text buttons on both sides of the navigation bar1. demand: all navigation bar on both sides of the text button unified style general style: Orange highlighted style: Red unavailable style: Bright gray shadow: Do not use font size: 15 github: https://github.com/hellovoidworld/HVWWeibo 2. default effect style: 1/** class calling */2 + (void) initialize {3 // initializing navigation bar style 4 [self initnavigationconfigureme] during initialization; 5 6 // initialize the item style in the navigation bar 7 [self initBarButtonItemTheme]; 8} 9 10/** set the style of the item in the navigation bar in a unified manner 11 * because the style of all NavivationBar is modified in a unified manner through the topic appearence, you can use the class method 12 */13 + (void) initBarButtonItemTheme {14 // set the navigation bar and modify the style of all UINavigationBar. 15 UIBarButtonItem * appearance = [UIBarButtonItem appearance]; 16 17 // set the style 18 NSMutableDictionary * normalTextAttr = [invalid dictionary]; 19 // font size 20 normalTextAttr [NSFontAttributeName] = [UIFont systemFontOfSize: 15]; 21 // font color 22 normalTextAttr [NSForegroundColorAttributeName] = [UIColor orangeColor]; 23 // set to normal style 24 [appearance setTitleTextAttributes: normalTextAttr forState: UIControlStateNormal]; 25 26 // set the style 27 NSMutableDictionary * optional = [invalid dictionaryWithDictionary: normalTextAttr]; 28 // The font color 29 highlightedTextAttr [encoding] = [UIColor redColor]; 30 // set to normal style 31 [appearance setTitleTextAttributes: Rule forState: Rule]; 32 33 // set the style 34 in the disabled state to disabledTextAttr = [Rule dictionaryWithDictionary: normalTextAttr]; 35 // font color 36 disabledTextAttr [Photo] = [UIColor lightGrayColor]; 37 // set to normal style 38 [appearance setTitleTextAttributes: disabledTextAttr forState: UIControlStateDisabled]; 39 40}B. Set the navigation bar style 1. Requirements:
- Uniform Text color: Black
- Text shadow: forbidden
- Font size: 20
1/** set the navigation bar style in a unified manner */2 + (void) initnavigationconfigureme {3 // use appearence (topic) settings, uniformly modify all navigation bar styles 4 UINavigationBar * appearance = [UINavigationBar appearance]; 5 6 // to unify iOS6 and iOS7, iOS6 needs to set a navigation bar background to simulate the effect of iOS7 7 if (! IOS7) {8 [appearance attributes: [UIImage imageWithNamed: @ "navigationbar_background"] forBarMetrics: Random]; 9} 10 11 // set attribute 12 NSMutableDictionary * attr = [random dictionary]; 13 // set the font 14 attr [NSForegroundColorAttributeName] = [UIColor blackColor]; 15 attr [NSFontAttributeName] = [UIFont systemFontOfSize: 20]; 16 // remove text shadow, set the shadow offset to 017 NSShadow * shadow = [[NSShadow alloc] init]; 18 shadow. shadowOffset = CGSizeZero; 19 attr [NSShadowAttributeName] = shadow; 20 21 [appearance setTitleTextAttributes: attr]; 22}