Giter Club home page Giter Club logo

atnavbarbutton's Introduction

ATNavBarButton 1.1

A sub-class of UIBarButtonItem to insert custom buttons or indicatorView into your navigationBar with one line of code.

Features

  • One line of code
  • One method to handle all button actions
  • Change to any button when needed
  • Custom indicator view and button colors
  • Change or add your own images
  • 35 Pre-defined FontAwesome icons on all 3 scales

Examples

Default Color:

ATNavBarButton1

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.navigationItem setLeftBarButtonItem:[ATNavBarButton setBarButton:ATNavBarButtonUser withDelegate:self]];
    [self.navigationItem setRightBarButtonItem:[ATNavBarButton setBarButton:ATNavBarButtonSettings withDelegate:self]];
}

Custom color:

ATNavBarButton2

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.navigationItem setLeftBarButtonItem:[ATNavBarButton setBarButton:ATNavBarButtonMenu withColor:UIColorFromRGB(0x5a4d8c) withDelegate:self]];
    [self.navigationItem setRightBarButtonItem:[ATNavBarButton setBarButton:ATNavBarButtonRefresh withColor:[UIColor redColor] withDelegate:self]];
}

Indicator view:

ATNavBarButton3

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.navigationItem setLeftBarButtonItem:[ATNavBarButton setBarButton:ATNavBarButtonArrowLeft withColor:UIColorFromRGB(0x5a4d8c) withDelegate:self]];
    [self loadIndicatorView:YES];
}

- (void)loadIndicatorView:(BOOL)loading
{
    if (loading) {
        [self.navigationItem setRightBarButtonItem:[ATNavBarButton setIndicatorButtonWithColor:[UIColor orangeColor] withDelegate:self]];
    } else {
        [self.navigationItem setRightBarButtonItem:[ATNavBarButton setBarButton:ATNavBarButtonRefresh withColor:[UIColor redColor] withDelegate:self]];
        // or [self.navigationItem setRightBarButtonItem:nil]; to remove the indicator or button if you don't have a manual refresh button
    }
}

Delegate

There's only left and right nav buttons, but you can set any button any time. Here is where you handle their actions:

- (void)ATNavBarButton:(ATNavBarButton *)barButton didPressBarButton:(ATNavBarButtonPressed)buttonPressed
{
    if (buttonPressed == ATNavBarButtonBack) {
        [self.navigationController popViewControllerAnimated:YES];
        
    } else if (buttonPressed == ATNavBarButtonArrowRight) {
        NextViewController *nextController = [NextViewController new];
        [self.navigationController pushViewController:nextController animated:YES];
        
    } else if (buttonPressed == ATNavBarButtonRefresh) {
        [self reloadContent];
        
    } else if (buttonPressed == ATNavBarButtonDownload) {
        [self downloadFile:@"https://www.emotality.com/development/GitHub/ATNavBarButton-1.png"];
    }
}

Installation

Manual:

  • Copy ATNavBarButton folder into your project
  • #import "ATNavBarButton.h" in the required class
  • Add the <ATNavBarButtonDelegate> protocol
  • Add the delegate method, ATNavBarButton:didPressBarButton:, like above

CocoaPods:

  • Add to podfile: pod 'ATNavBarButton'
  • #import "ATNavBarButton.h" in the required class
  • Add the <ATNavBarButtonDelegate> protocol
  • Add the delegate method, ATNavBarButton:didPressBarButton:, like above

License

ATAppUpdater is released under the MIT license. See LICENSE for details.

atnavbarbutton's People

Contributors

emotality avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.