ios UIView动画

作者: oc123 | 来源:发表于2017-05-11 10:56 被阅读3次

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

相关文章

网友评论

    本文标题:ios UIView动画

    本文链接:https://www.haomeiwen.com/subject/zwzntxtx.html