侧边栏的实现----网易新闻的侧边栏效果
来源:互联网 发布:数据库系统概论第5版11 编辑:程序博客网 时间:2024/06/02 23:43
在最近的项目里面要实现侧边栏的效果,基于时间紧迫自己代码封装实现侧边栏的时间不允许,所以使用了现有的第三方框架的代码实现,现主要列举两个实现的效果
现在自己的项目里面导入第三方框架文件DDMenuController MMDrawerController
下面是具体的实现效果
1、DDMenuController
Appdelegate.h里面定义变量的属性
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (retain, nonatomic) DDMenuController *ddmenuVC;
@property (retain, nonatomic) MainTabBarController *mainTBC;
@property (retain,nonatomic) LoginTabBarViewController *LoginTBC;
@end
在Appdelegate.m里面写入下面的代码
self.mainTBC = [[[MainTabBarController alloc]initWithNibName:nil bundle:nil] autorelease];
LoginViewController *LoginVC = [[LoginViewController alloc]initWithNibName:@"LoginViewController" bundle:nil];
//初始化DDMenu,并设置2个VC
self.ddmenuVC = [[DDMenuControlle alloc]initWithRootViewController:self.mainTBC];
self.ddmenuVC.leftViewController = LoginVC;
self.window.rootViewController = self.ddmenuVC;
这样即可用DDMenuControlle实现侧边栏滑动实现的效果,但是DDMenuControlle可以实现左侧菜单的滑动展开,不能实现滑动隐藏,隐藏是点击按钮以及点击界面实现,所以很多人实现的时候会对这一效果很不满意。所以下面介绍另外一种实现侧边的效果,可以实现滑动展开以及滑动隐藏。
2、MMDrawerController
Appdelegate.h里面定义变量的属性
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (nonatomic,retain) MMDrawerController *mmMenuVC;
@property (retain, nonatomic) MainTabBarController *mainTBC;
@property (retain, nonatomic) LoginTabBarViewController *LoginTBC;
在Appdelegate.m里面写入下面的代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
self.mainTBC = [[[MainTabBarController alloc] initWithNibName:nil bundle:nil]autorelease];
leftVC = [[LeftViewController alloc] initWithNibName:@"LeftViewController" bundle:nil];
mmMenuVC = [[MMDrawerController alloc] initWithCenterViewController:self.mainTBC leftDrawerViewController:leftVC];
self.window.rootViewController = self.mmMenuVC;
[mmMenuVC setMaximumLeftDrawerWidth:kPublicLeftMenuWidth];
[mmMenuVC setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
[mmMenuVC setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll];
[mmMenuVC setDrawerVisualStateBlock:^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) {
MMDrawerControllerDrawerVisualStateBlock block;
block = [MMDrawerVisualState parallaxVisualStateBlockWithParallaxFactor:2.0];
block(drawerController, drawerSide, percentVisible);
}];
return YES;
}
MMDrawerController实现的功能比较强大,可以实现滑动实现菜单的效果。
- 侧边栏的实现----网易新闻的侧边栏效果
- 侧边栏的实现
- SlidingMenu侧边栏的实现
- js实现侧边栏效果
- 简单的侧边栏
- jquery侧边栏效果
- ios侧边栏效果
- 笔记-侧边栏效果
- 抽屉效果侧边栏
- 侧边栏滑动效果
- 基于CCoolBar侧边栏的实现
- WordPress侧边栏漂浮的实现
- android slidingMenu 侧边栏菜单 的实现
- Android开发--滑动侧边栏的实现
- Android 侧边字母导航栏的实现
- 侧边栏的实现(一)
- 侧边栏的实现(二)
- 侧边栏的实现(三)
- cocos2dx之闪烁效果-CCBlink
- C++ 命名空间namespace
- 多科成绩单
- 【PAT 1030】Travel Plan 最短路径Dijkstra
- 算法
- 侧边栏的实现----网易新闻的侧边栏效果
- OpenGL 学习笔记一
- 【算法与数据结构】最大子序列和问题
- 关于sqlserver、access、mysql数据库性能的一个简单测试
- Socket网络通信方式/模型
- Base64加解密
- 【C语言学习笔记】字符串拼接的3种方法
- 常用HQL语句
- R语言进阶之3:数据汇总/透视/提炼