标签:
@property (nonatomic, strong)UIImageView *choytiimage;
@property (nonatomic, strong)UIButton *choutibutton;
@property (nonatomic, strong)UIButton *button;
@property (nonatomic, strong)UILabel *label;
@property (nonatomic, strong)UILabel *label1;
@property (nonatomic, strong)UILabel *label2;
@property (nonatomic, strong)UIView *aview;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
//利用layer层来隐藏 刚开始View是隐藏的 在BUtton点击方法里它会发挥用处
_aview = [[UIView alloc]init];
_aview.frame = CGRectMake(-200, 0,200, 667);
_aview.backgroundColor = [UIColor orangeColor];
[self.view addSubview:_aview];
//label也处于隐藏
_label = [[UILabel alloc]initWithFrame:CGRectMake(-200, 200, 60, 30)];
_label.text = @"图片";
_label.textAlignment = NSTextAlignmentCenter;
_label.textColor = [UIColor blueColor];
[self.view addSubview:_label];
_label1 = [[UILabel alloc]initWithFrame:CGRectMake(-200, 240, 60, 30)];
_label1.text = @"作品";
_label1.textColor = [UIColor redColor];
_label1.textAlignment = NSTextAlignmentCenter;
[self.view addSubview:_label1];
_label2 = [[UILabel alloc]initWithFrame:CGRectMake(-200, 280, 60, 30)];
_label2.text = @"展示";
_label2.textAlignment = NSTextAlignmentCenter;
_label2.textColor = [UIColor purpleColor];
[self.view addSubview:_label2];
_choytiimage = [[UIImageView alloc]init];
_choytiimage.frame = CGRectMake(0, 0, 375, 667);
_choytiimage.image = [UIImage imageNamed:@"433.jpg"];
[self.view addSubview:_choytiimage];
_choutibutton = [UIButton buttonWithType:UIButtonTypeCustom];
[_choutibutton setTitle:@"抽屉" forState:UIControlStateNormal];
_choutibutton.frame = CGRectMake(10, 50, 60, 30);
[_choutibutton setTitleShadowColor:[UIColor orangeColor] forState:UIControlStateNormal];
[_choutibutton addTarget:self action:@selector(choyti:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:_choutibutton];
_button = [UIButton buttonWithType:UIButtonTypeCustom];
[_button setTitle:@"返回" forState:UIControlStateNormal];
_button.frame = CGRectMake(300, 50, 60, 30);
[_button setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
[_button addTarget:self action:@selector(rtr:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:_button];
}
-(void)choyti:(UIButton *)sender
{
//抽屉效果主要的就是 在于UIView的动画效果 View从-200 通过动画效果展示出来
[UIView animateWithDuration:1.5f animations:^{
_choytiimage.frame = CGRectMake(200, 0, 200, 667);
}];
[UIView animateWithDuration:2.0f animations:^{
_label.frame = CGRectMake(22, 200, 60, 30);
}];
[UIView animateWithDuration:2.2f animations:^{
_label1.frame = CGRectMake(22, 240, 60, 30);
}];
[UIView animateWithDuration:2.4f animations:^{
_label2.frame = CGRectMake(22, 280, 60, 30);
}];
[UIView animateWithDuration:1.5f animations:^{
_aview.frame = CGRectMake(0, 0, 200, 667);
}];
}
-(void)rtr:(UIButton *)sender
{ [UIView animateWithDuration:2.0f animations:^{
//点击返回按钮 恢复原来image
_choytiimage.frame = CGRectMake(0, 0, 375, 667);
}];
}


标签:
原文地址:http://my.oschina.net/u/2380958/blog/490754