耶!!

你总是这样轻言放弃的话,无论过多久都会在原地踏步

从底部弹出来一个view动画

@property(nonatomic,assign)BOOL isOne;  


    UIButton *btn = [UIButton buttonWithType:UIButtonTypeContactAdd];
    [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];

-(void)btnClick{
    if(self.isOne){
        UIView*actionView = [self.view viewWithTag:ActionViewTag];
        [UIView animateWithDuration:0.5 animations:^{
            actionView.frame = CGRectMake(0, UIScreenHeight, UIScreenHeight, UIScreenHeight/2);
        [UIView setAnimationDidStopSelector:@selector(removeActionView)];
        }];
        self.isOne = NO;
    }else{
        UIView*actionView = [self.view viewWithTag:ActionViewTag];
        if (!actionView) {
            [self addActionView];
            actionView = [self.view viewWithTag:ActionViewTag];
        }
        [UIView animateWithDuration:0.5 animations:^{
            actionView.frame = CGRectMake(0, UIScreenHeight/2, UIScreenHeight, UIScreenHeight/2);
        }];
        self.isOne = YES;
    }
}
-(void)addActionView{
    UIView*view = [[UIView alloc] init];
    view.frame = CGRectMake(0, UIScreenHeight, UIScreenHeight, UIScreenHeight/2);
    view.tag = ActionViewTag;
    view.backgroundColor = [UIColor blueColor];
    [self.view addSubview:view];
}
-(void)removeActionView{
    UIView*actionView = [self.view viewWithTag:ActionViewTag];
    if (actionView) {
        [actionView removeFromSuperview];
    }
}



阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/jianandjan/article/details/49930503
个人分类: 动画
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭