打开和关闭表单动画

时间:2015-06-14 06:48:13

标签: ios ios8 core-animation ios-animations

这个动画在iOS中是否可行,是否有任何第三方API?

enter image description here

1 个答案:

答案 0 :(得分:1)

使用嵌套动画计算自己

-(void)viewDidLoad
{

    expandiView = [[UIView alloc] initWithFrame:CGRectMake(137, 269, 30, 2
                                                            )];
    expandiView.backgroundColor = [UIColor redColor];
    [self.view addSubview:expandiView];
    expandiView.hidden=YES;

}

-(IBAction)Expand:(id)sender {

    expandiView.hidden=NO;


    [UIView animateWithDuration:0.5f
                     animations:^{

                         expandiView.frame = CGRectMake(60, 269, 200, 2);
                     }
                     completion:^(BOOL finished) {
                         [UIView animateWithDuration:1
                                          animations:^{
                                              expandiView.frame = CGRectMake(60, 269, 200, 100);

                                          }];
                     }];

}





-(IBAction)collapse:(id)sender {



    [UIView animateWithDuration:0.5f
                     animations:^{
                         expandiView.frame = CGRectMake(60, 269, 200, 2);

                     }
                     completion:^(BOOL finished) {
          [UIView animateWithDuration:0.5f animations:^{
                             expandiView.frame = CGRectMake(137, 269, 30, 2);
                         } completion:^(BOOL finished) {
                             expandiView.hidden=YES;
                         }];
                     }];


}