Swiftpack.co -  AndreasVerhoeven/UIKitAnimations as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
AndreasVerhoeven/UIKitAnimations
Provide a few helpers for animating common UIKit operations, such as setting text
.package(url: "https://github.com/AndreasVerhoeven/UIKitAnimations.git", from: "1.0.0")

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 another

  • view.performTransitionIfNeeded() same, but only if the animated parameter is true

  • UIView.performAnimationsIfNeeded() only animates the changes if the animated parameter is true

  • view.shake() shakes the view, usually to indicate an error

  • view.shakeWithHapticErrorFeedback() same, but with haptic error feedback

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()
}

UIImageView

  • setImage(_:animated:) sets a new image with a crossfade transition, if animated is true
  • setImage(_:tintColor:animated) same, but with a tint color parameter

Example:

imageView.setImage(UIImage(systemNamed: "gearshape"), tintColor: .red, animated: true)

UILabel & UITextView

  • setText(_: animated:) sets new text with a crossfade transition, if animated is true
  • setAttributedText(_:animated:) same, but for attributed text
  • setText(_:textColor:animated:) same, but text & color
  • setTextColor(_:animated:) same, but only text color

Example:

label.setText("New text", animated: true)
textView.setAttributedText(newAttributedText, animated: true)

UIWindow

  • switchRootViewController() changes the root view controller, with a cross fade animation if wanted

Example:

window.setRootViewController(newViewController, animated: true)

DisplayLink

DisplayLink is a small wrapper around CADisplayLink that uses a block callback and stops the display link whenever it gets deallocated.

Example:

var displayLink = DisplayLink.started {
	print("frame")
}

DispatchQueue.main.asyncAfter(.now() + 1) {
	displayLink = nil
}

GitHub

link
Stars: 1
Last commit: 1 week ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API