swift 约束动画

约束动画

Constraint.swift
view.layoutIfNeeded()     // Optional. Ensure that all pending layout operations have been completed
UIView.animateWithDuration(5) {
  someConstraint.constant = 0
  self.view.layoutIfNeeded()   // called on parent view
}

swift GCD

GCD.swift
DispatchQueue.global(qos: .userInitiated).async { [unowned self] in
    ...
    DispatchQueue.main.async { [unowned self] in
       ... 
    }
}

// Delay execution of the block
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
    ...
}