Set the navigation bar topic in IOS development and the navigation bar topic in ios development

Source: Internet
Author: User

Set the navigation bar topic in IOS development and the navigation bar topic in ios development

/*** The system calls this class for the first time (only one class is called once) */+ (void) initialize {// set the navigation bar topic UINavigationBar * navBar = [UINavigationBar appearance]; // set the background image NSString * bgName = nil; if (iOS7) {// iOS 7.0 bgName = @ "NavBar64";} else {// non-iOS7 bgName = @ "NavBar";} [navBar setBackgroundImage: [UIImage imageNamed: bgName] forBarMetrics: UIBarMetricsDefault]; // set the title text color NSMutableDictionary * attrs = [NSMutableDictionary dic Tionary]; attrs [NSForegroundColorAttributeName] = [UIColor whiteColor]; attrs [NSFontAttributeName] = [UIFont systemFontOfSize: 16]; [navBar setTitleTextAttributes: attrs]; // set the topic UIBarButtonItem * item = [UIBarButtonItem appearance]; // set the text color to optional * itemAttrs = [invalid dictionary]; itemAttrs [character] = [UIFont systemFontOfSize: 14]; itemAttrs [NSForeground ColorAttributeName] = [UIColor whiteColor]; [item setTitleTextAttributes: itemAttrs forState: UIControlStateNormal]; if (! IOS7) {// set the button background [item setBackgroundImage: [UIImage imageNamed: @ "NavButton"] forState: UIControlStateNormal barMetrics: UIBarMetricsDefault]; [item attributes: [UIImage imageNamed: @ "NavButtonPressed"] forState: Alert barMetrics: UIBarMetricsDefault]; // set the background of the return button [item Background: [UIImage imageNamed: @ "NavButton"] forState: UIControlStateNormal barMetrics: UIBarMetricsDefault]; [item representation: [UIImage imageNamed: @ "NavButtonPressed"] forState: UIControlStateHighlighted barMetrics: UIBarMetricsDefault];} else {navBar. tintColor = [UIColor whiteColor] ;}}

  

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.