GitHub地址:https://github.com/gotosleep/JASidePanels
Demo地址:http://download.csdn.net/detail/u012881779/8833961
JASidePanels是一个很实用的第三方的侧滑工具
#import "AppDelegate.h"
#import "HomeViewController.h"
#import "LeftPanelViewController.h"
#import "RightPanelViewController.h"
#import "JASidePanelController.h"
@interface AppDelegate ()
@property (strong, nonatomic) UINavigationController *nav;
@end
@implementation AppDelegate
@synthesize nav = _nav;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
HomeViewController* home = [[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil];
LeftPanelViewController* left = [[LeftPanelViewController alloc] initWithNibName:@"LeftPanelViewController" bundle:nil];
RightPanelViewController* right = [[RightPanelViewController alloc] initWithNibName:@"RightPanelViewController" bundle:nil];
//侧滑栏
JASidePanelController *panelVC = [[JASidePanelController alloc] init];
panelVC.leftPanel = left;
panelVC.rightPanel = right;
panelVC.centerPanel = home;
//导航
_nav = [[UINavigationController alloc] initWithRootViewController:panelVC];
[_nav setNavigationBarHidden:YES];
self.window.rootViewController = _nav;
[self.window makeKeyAndVisible];
return YES;
}
首页:
#import "HomeViewController.h"
#import "JASidePanelController.h"
@interface HomeViewController ()
@end
@implementation HomeViewController
- (IBAction)leftPanelAction:(id)sender {
[[JASidePanelController share] toggleLeftPanel:nil];
}
- (IBAction)rightPanelAction:(id)sender {
[[JASidePanelController share] toggleRightPanel:nil];
}
@end
JASidePanel设置侧栏参数:
#import <QuartzCore/QuartzCore.h>
#import "JASidePanelController.h"
@interface JASidePanelController()
@end
@implementation JASidePanelController
- (void)_baseInit {
[[UIApplication sharedApplication] setStatusBarHidden:NO];
self.style = JASidePanelSingleActive;
//左侧栏目比例
self.leftGapPercentage = 0.52f;
//右侧栏目比例
self.rightGapPercentage = 0.8f;
self.minimumMovePercentage = 0.15f;
self.maximumAnimationDuration = 0.2f;
self.bounceDuration = 0.1f;
self.bouncePercentage = 0.075f;
self.panningLimitedToTopViewController = YES;
self.recognizesPanGesture = YES;
self.allowLeftOverpan = YES;
self.allowRightOverpan = YES;
self.bounceOnSidePanelOpen = YES;
self.shouldDelegateAutorotateToVisiblePanel = YES;
}
@end
示意图: