iOS自定义视图的放大缩小的动画

边浩波
2023-12-01
/** 设置缩放动画 */
- (void)startScaleAnimation:(UIView *)view {
    // 放大动画
    [UIView animateWithDuration:0.2 animations:^{
        view.transform = CGAffineTransformMakeScale(1.2, 1.2); //等比放大1.2倍
    } completion:^(BOOL finished) {
        // 缩回去动画
        [UIView animateWithDuration:0.1 animations:^{
            view.transform = CGAffineTransformIdentity; //回复原始状态
        } completion:^(BOOL finished) {
            // 放大动画
            [UIView animateWithDuration:0.08 animations:^{
                view.transform = CGAffineTransformMakeScale(1.1, 1.1); //等比放大1.1倍
            } completion:^(BOOL finished) {
                // 缩回去动画
                [UIView animateWithDuration:0.04 animations:^{
                    view.transform = CGAffineTransformIdentity; //回复原始状态
                }];
            }];
        }];
    }];
}
 类似资料: