iOS 仿照网易侧栏效果demo
这是一个仿照网易客户端侧栏效果(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
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。