iOS UIview简单的缩放动画

// 创建一个背景
self.bgView = [UIView new];
    [self addSubview:self.bgView];
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.bounds.origin.x);
        make.centerY.mas_equalTo(self.bounds.origin.y);
        make.width.mas_equalTo(alertWidth * kWIDTH);//宽度自己设置 300
        make.height.mas_equalTo(alertHeight * kHEIGHT);// 高度自己设置 200
    }];
   self.bgView.backgroundColor = [UIColor redColor]; 

// 0.2 表示动画时长为0.2秒
[UIView animateWithDuration:0.2 animations:^{
       
       // transform 使...变形
       // CGAffineTransformMakeScale(1.2, 1.2) 缩放的比例 缩放为原来的1.2倍
        self.bgView.transform = CGAffineTransformMakeScale(1.2, 1.2);
    } completion:^(BOOL finished) {
        // 完成后要将视图还原
        // CGAffineTransformIdentity
        [UIView animateWithDuration:0.2 animations:^{
            self.bgView.transform = CGAffineTransformIdentity;
        }];
    }];

你可能感兴趣的:(iOS UIview简单的缩放动画)