Giter VIP home page Giter VIP logo

pcsidebarcontroller's Introduction

PCSideBarController

UIViewController which provide navigation via a side bar.

Side bar items are to select view controller and manage also actions buttons.

Usage

Sample project using SideBarController under /Example: PCSideBarController Sample.xcodeproj

Here is a quick show :

alt tag

###SideBarController

PCSideBarController* sideBarController = [[PCSideBarController alloc]init];

// Set a delegate if you want a callback on didSelectViewController:

sideBarController.delegate = self;

// Set SideBar background color

sideBarController.sideBarBackgroundColor = [UIColor yellowColor];

// Set a SideBar border (default NO)

sideBarController.drawBorder = YES;

// Set First item offset from top of sideBar view (default 0)

sideBarController.leadingOffset = 100.0f;

// Set Last item offset from bottom of sideBar view (default 0)

sideBarController.tailingOffset = 20.0f;

// Set overlay color of selected item

sideBarController.sideBarItemHighlightedColor = [UIColor redColor];

// Assign viewControllers for sideBar

sideBarController.viewControllers = @[[[BookmarksViewController alloc] init],
                                       [[TodayViewController alloc] init]];

// Add buttons items to sideBar (will be displayed after VC items)
// Buttons items are not attached to any VC, they are to handle any action.

PCSideBarItem* pinActionItem = [[PCSideBarItem alloc]init];
pinActionItem.image = [UIImage imageNamed:@"pin"];

// Block action on touch

pinActionItem.itemTouched = ^(NSIndexPath* indexPath){
  UIAlertView* alertView = [[UIAlertView alloc]initWithTitle:@"SideBar Button Item" message:@"Pin Action" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:nil];
  [alertView show];
};

// Block action on long touch

pinActionItem.itemLongPressed = ^(NSIndexPath* indexPath){
  UIAlertView* alertView = [[UIAlertView alloc]initWithTitle:@"SideBar Button Item" message:@"Pin Action when long pressed" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:nil];
  [alertView show];
};

// Assign actions items to side bar VC

sideBarController.buttonsItems = @[pinActionItem];

// Set Action Item active/inactive

[sideBarController setActionItemAtIndex:0 active:YES];

// Reload SideBar

//[_sideBarController reloadSideBar];

// Reload Selected View Controller content view

//[_sideBarController reloadContentView];

PCSideBarControllerDelegate

Protocol : PCSideBarControllerDelegate
Optional method : sideBarController:didSelectViewController:


- (void)sideBarController:(PCSideBarController *)sideBarController didSelectViewController:(UIViewController *)viewController
{
  NSLog(@"ViewController %@ Selected", viewController.class);
}

View controller assigned to SideBarController configuration

@implementation BookmarksViewController

- (id)init
{
  self = [super init];
  if (self) {
    self.sideBarItem.image = [UIImage imageNamed:@"bookmark"];
    self.sideBarItem.title = @"Bookmarks";
  }
  return self;
}
...
@end

Installation

Copy sources files Classes/ios/*.{h,m}

PCSideBarController is available through CocoaPods, to install it simply add the following line to your Podfile:

pod "PCSideBarController"

Changelog

Author

anoiaque, [email protected]

License

PCSideBarController is available under the MIT license. See the LICENSE file for more info.

pcsidebarcontroller's People

Watchers

James Cloos avatar Kunal Sood 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.