码迷,mamicode.com
首页 > 移动开发 > 详细

iOS 仿照网易侧栏效果demo

时间:2015-04-22 15:17:02      阅读:189      评论:0      收藏:0      [点我收藏+]

标签: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 仿照网易侧栏效果demo

标签:ios侧边栏菜单解决方案   ios左右侧栏   ios中左右两侧导航栏的简单实现   ios 侧边栏菜单   ios 侧边栏菜单实现   

原文地址:http://blog.csdn.net/mjbaishiyun/article/details/45194951

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!