Skip to content

Repository files navigation

JXGradientNavigationBar

Custom UINavigationBar subclass with gradient colors on iOS.

Version License Platform

Screen Shot

Screen Shot

Requirements

Installation

Add the following line to your Podfile:

pod "JXGradientNavigationBar"

Usage

  1. Import the header file:
#import "JXGradientNavigationBar.h"
  1. Set the gradient colors using UIAppearance barTintGradientColors property:
[JXGradientNavigationBar appearance].barTintGradientColors = @[[UIColor greenColor], [UIColor yellowColor]];
  1. Customize your navigation controller:
UINavigationController * navigationController = [[UINavigationController alloc] initWithNavigationBarClass:[JXGradientNavigationBar class] toolbarClass:nil];

Example

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

  [JXGradientNavigationBar appearance].barTintGradientColors = @[[UIColor greenColor], [UIColor yellowColor]];
  [JXGradientNavigationBar appearance].shadowImage = [[UIImage alloc] init];
  [JXGradientNavigationBar appearance].tintColor = [UIColor whiteColor];
  [JXGradientNavigationBar appearance].titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor]};

  UINavigationController * navigationController = [[UINavigationController alloc] initWithNavigationBarClass:[JXGradientNavigationBar class] toolbarClass:nil];
  navigationController.navigationBar.translucent = YES;
  navigationController.viewControllers = @[[[UIViewController alloc] init]];

  self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
  [self.window setRootViewController:navigationController];
  [self.window makeKeyAndVisible];

  return YES;
}

Sponsors

License

Copyright © 2015 Jianqiu Xiao swordray@gmail.com under The MIT License.

About

Custom UINavigationBar subclass with gradient colors on iOS.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages