抽屉效果

1.导航控制器在AppDelegate.m中
在这里插入图片描述
2.V.m中

#import "ViewController.h"
#define hcheight [UIScreen mainScreen].bounds.size.height
@interface ViewController ()<UITableViewDelegate,UITableViewDataSource>{
    UIView *leftvie;
    UIView *zhuvie;
    UIButton *btn;
    UITableView *tab;
    UIView *img;
}

@end

@implementation ViewController

-(void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title=@"主";
    
    UIView *vie=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
    btn=[[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
    [btn setImage:[UIImage imageNamed:@"1.jpg"] forState:UIControlStateNormal];
    btn.layer.masksToBounds=YES;
    btn.layer.cornerRadius=20;
    [vie addSubview:btn];
    [btn addTarget:self action:@selector(abc) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc] initWithCustomView:vie];
    
    leftvie=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, hcheight)];
    leftvie.backgroundColor=[UIColor redColor];
    [self.view addSubview:leftvie];
    
    tab=[[UITableView alloc] initWithFrame:CGRectMake(0, 250, 300, 300) style:UITableViewStylePlain];
    tab.delegate=self;
    tab.dataSource=self;
    [leftvie addSubview:tab];
    
    img=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 300,250 )];
    UIImageView *imgv = [[UIImageView alloc]initWithFrame:CGRectMake((300-80)/2, 50, 80, 80)];
    imgv.image = [UIImage imageNamed:@"1.jpg"];
    UILabel *la = [[UILabel alloc]initWithFrame:CGRectMake((300-100)/2, 140, 100, 30)];
    la.text = @"134*****273";
    UILabel *la1 = [[UILabel alloc]initWithFrame:CGRectMake((300-70)/2, 170, 70, 30)];
    la1.text = @"普通用户>";
    la1.font = [UIFont systemFontOfSize:13];
    [leftvie addSubview:imgv];
    [leftvie addSubview:la];
    [leftvie addSubview:la1];
    [leftvie addSubview:img];
    
    zhuvie=[[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, hcheight)];
    zhuvie.backgroundColor=[UIColor cyanColor];
    [self.view addSubview:zhuvie];
  

    
    
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 6;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *oj=@"cell";
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:oj];
    if (cell==nil) {
        cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:oj];
    }
    cell.imageView.image = [UIImage imageNamed:@"13"];
    cell.textLabel.text = @"订单";
    
    return cell;
    
}

        






-(void)abc{
    if (btn.selected==NO) {
        [UIView animateWithDuration:0.5 animations:^{
            zhuvie.transform=CGAffineTransformMakeTranslation(300, 0);
            self.navigationController.navigationBar.transform=CGAffineTransformMakeTranslation(300, 0);
        }];
        btn.selected=YES;
    }else{
        [UIView animateWithDuration:0.5 animations:^{
            zhuvie.transform=CGAffineTransformIdentity;
            self.navigationController.navigationBar.transform=CGAffineTransformIdentity;
        }];
        btn.selected=NO;
    }
}

@end


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值