Adds CGAffineTransform(to:from:) for CGPoints
Provide a few helpers for animating common UIKit operations, such as setting text
This library provides a few helper functions for easily animating common UIKit operations, such as setting text and images.
view.performTransition() does a cross fade of the view from one state to another
view.performTransition()
view.performTransitionIfNeeded() same, but only if the animated parameter is true
view.performTransitionIfNeeded()
animated
UIView.performAnimationsIfNeeded() only animates the changes if the animated parameter is true
UIView.performAnimationsIfNeeded()
view.shake() shakes the view, usually to indicate an error
view.shake()
view.shakeWithHapticErrorFeedback() same, but with haptic error feedback
view.shakeWithHapticErrorFeedback()
Example:
view.performTransition { // update some complex view here, changes will crossfade } view.performTransitionIfNeeded(animated: true) { // update some complex view here, changes will crossfade } // indicates an error by shaking a textfield inputTextField.shakeWithHapticErrorFeedback { inputTextField.becomeFirstResponder() }
setImage(_:animated:)
setImage(_:tintColor:animated)
imageView.setImage(UIImage(systemNamed: "gearshape"), tintColor: .red, animated: true)
setText(_: animated:)
setAttributedText(_:animated:)
setText(_:textColor:animated:)
setTextColor(_:animated:)
label.setText("New text", animated: true) textView.setAttributedText(newAttributedText, animated: true)
switchRootViewController()
window.setRootViewController(newViewController, animated: true)
DisplayLink is a small wrapper around CADisplayLink that uses a block callback and stops the display link whenever it gets deallocated.
CADisplayLink
var displayLink = DisplayLink.started { print("frame") } DispatchQueue.main.asyncAfter(.now() + 1) { displayLink = nil }
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
UIKitAnimations
Provide a few helpers for animating common UIKit operations, such as setting text
What?
This library provides a few helper functions for easily animating common UIKit operations, such as setting text and images.
UIView
view.performTransition()
does a cross fade of the view from one state to anotherview.performTransitionIfNeeded()
same, but only if theanimated
parameter is trueUIView.performAnimationsIfNeeded()
only animates the changes if theanimated
parameter is trueview.shake()
shakes the view, usually to indicate an errorview.shakeWithHapticErrorFeedback()
same, but with haptic error feedbackExample:
UIImageView
setImage(_:animated:)
sets a new image with a crossfade transition, if animated is truesetImage(_:tintColor:animated)
same, but with a tint color parameterExample:
UILabel & UITextView
setText(_: animated:)
sets new text with a crossfade transition, if animated is truesetAttributedText(_:animated:)
same, but for attributed textsetText(_:textColor:animated:)
same, but text & colorsetTextColor(_:animated:)
same, but only text colorExample:
UIWindow
switchRootViewController()
changes the root view controller, with a cross fade animation if wantedExample:
DisplayLink
DisplayLink is a small wrapper around
CADisplayLink
that uses a block callback and stops the display link whenever it gets deallocated.Example: