UIView简单的frame改变动画,代码如下:
#import "ViewController.h"
#define screenW self.view.bounds.size.width
#define screenH self.view.bounds.size.height
@interface ViewController ()
{
UIView *animationView;
UIToolbar *toolbar;//遮罩
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self setViewForAnimation];
}
-(void)setViewForAnimation{
toolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, screenH, screenW, screenH - 200)];
//样式
toolbar.barStyle = UIBarStyleBlackTranslucent;//半透明
//透明度
toolbar.alpha = 0.5f;
[self.view addSubview:toolbar];
animationView = [[UIView alloc]initWithFrame:CGRectMake(0, screenH, screenW, 200)];
[self.view addSubview:animationView];
}
/**
* xib - button click
*/
- (IBAction)performViewAnimation:(UIButton *)sender {
[UIView animateWithDuration:1 animations:^{
toolbar.frame = CGRectMake(0, 0, screenW, screenH - 200);
animationView.frame = CGRectMake(0, screenH - 200, screenW, 200);//最终frame
}];//触屏 - 触发UIView动画
}
@end