PCSideBarController 1.0.4

PCSideBarController 1.0.4

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2014年12月

未声明 维护。




提供侧边栏导航的 UIViewController。

侧边栏项目用于选择视图控制器,同时管理动作按钮。

使用方法

在 /Example 目录下使用 SideBarController 的示例项目: PCSideBarController Sample.xcodeproj

这是一个快速展示

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);
}

分配给 SideBarController 的视图控制器配置

@implementation BookmarksViewController

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

安装

复制源文件 Classes/ios/*.{h,m}

作者

anoiaque, [email protected]

许可证

PCSideBarController 在 MIT 许可证下提供。有关更多信息,请参阅 LICENSE 文件。