zoukankan      html  css  js  c++  java
  • 约束动画

    -(void)modifyConstraint:(UIButton *)btn{
        btn.translatesAutoresizingMaskIntoConstraints = NO;
        NSArray* constrains = btn.constraints;
        NSLayoutConstraint *widthConstraint = [NSLayoutConstraint constraintWithItem:btn attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1 constant:0];
        for (NSLayoutConstraint* constraint in constrains) {
            if (constraint.firstAttribute == NSLayoutAttributeWidth) {
                [UIView animateWithDuration:1 animations:^{
                    
                    [btn addConstraint:widthConstraint];
                    [btn removeConstraint:constraint];
                    [btn layoutIfNeeded];
                } completion:^(BOOL finished) {
                   
                    dispatch_time_t timer =
                    dispatch_time(DISPATCH_TIME_NOW,
                                  0.5 *
                                  NSEC_PER_SEC);
                    dispatch_after(timer, dispatch_get_main_queue(), ^{
                        [UIView animateWithDuration:.3 animations:^{
                            [btn removeConstraint:widthConstraint];
                            [btn addConstraint:[NSLayoutConstraint constraintWithItem:btn attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1 constant:40]];
                            [btn layoutIfNeeded];
                        } completion:^(BOOL finished) {
    
                        }];
                    });
                }];
                break;
            }
        }
    }
    
  • 相关阅读:
    三次请求(读-改-读)引出nibernate 一级缓存
    算法竞赛入门经典第一、二章摘记
    uva 10905 Children's Game
    uva 11205 The broken pedometer
    uva 10160 Servicing stations
    uva 208 Firetruck
    uva 167 The Sultan's Successors
    zoj 1016 Parencodings
    uva 307 Sticks
    uva 216 Getting in Line
  • 原文地址:https://www.cnblogs.com/guligei/p/9767416.html
Copyright © 2011-2022 走看看