这个动画在iOS中是否可行,是否有任何第三方API?
答案 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;
}];
}];
}