iOS UIview简单的缩放动画

作者: 程序小胖 | 来源:发表于2017-03-09 12:39 被阅读1575次
    // 创建一个背景
    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简单的缩放动画

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