标签:ios侧边栏菜单解决方案 ios左右侧栏 ios中左右两侧导航栏的简单实现 ios 侧边栏菜单 ios 侧边栏菜单实现
这是一个仿照网易客户端侧栏效果(demo),用最简单的方法实现,以下只是一部分代码:有兴趣的同学可以到gitHub下载,下载地址:demo
#import "ViewController.h"
#import "BSYItem.h"
#import "BSYView.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"首页";
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"bar"] forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:[UIColor yellowColor] forKey:NSForegroundColorAttributeName];
// 左侧按钮
self.left = [[BSYItem alloc]init];
self.navigationItem.leftBarButtonItem = [self.left addLeft];
self.left.left.selected = NO;
[self.left .left addTarget:self action:@selector(leftclick:) forControlEvents:UIControlEventTouchUpInside];
}
-(void)leftclick:(UIButton *)button
{
self.left.left.selected =! button.selected;
if (self.left.left.selected==YES) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationsEnabled:YES];
self.slide.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width/4, [UIScreen mainScreen].bounds.size.height);
[UIView commitAnimations];
}else{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationsEnabled:YES];
self.slide.frame = CGRectMake(0, 0, 0, [UIScreen mainScreen].bounds.size.height);
[UIView commitAnimations];
}
[self addbuttonClick];
}
下载代码:BSYTheSideBar
标签:ios侧边栏菜单解决方案 ios左右侧栏 ios中左右两侧导航栏的简单实现 ios 侧边栏菜单 ios 侧边栏菜单实现
原文地址:http://blog.csdn.net/mjbaishiyun/article/details/45194951