Widgets iOS 14 animation with 3D and dynamic shadow. Customisable transform and duration.

Overview

SPPerspective

About

Animatable widgets from iOS 14. Same animation for transform and shadow.

Customisable duration, perspective and shadow also. For visual edit use example app, check video preview:

https://opensource.ivanvorobei.by/spperspective/preview

If you like the project, don't forget to put star ★
Check out my other libraries:

Navigate

Installation

Ready for use on iOS 12+. Works with Swift 5+. Required Xcode 12.0 and higher.

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.

Once you have your Swift package set up, adding as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/ivanvorobei/SPPerspective.git", .upToNextMajor(from: "1.4.1"))
]

CocoaPods:

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate using CocoaPods, specify it in your Podfile:

pod 'SPPerspective'

Manually

If you prefer not to use any of dependency managers, you can integrate manually. Put Sources/SPPerspective folder in your Xcode project. Make sure to enable Copy items if needed and Create groups.

Quick Start

For apply animation for your view, use this code:

view.applyPerspective(.iOS14WidgetAnimatable)

Use this, if need apply non-animation transform:

view.applyPerspective(.iOS14WidgetStatic)

Customise

Summary

You can customise duration, angle, shadow properties and other. All this customising by configuration file. Configuration can be animatable or static. Above you see .iOS14WidgetAnimatable & .iOS14WidgetStatic, its also configurations wich already have good-usage values same as native widgets.

For get fine configuration, better use example app (video preview). You can in real time see changes in configuration.

https://opensource.ivanvorobei.by/spperspective/preview

Next more details about customise.

Duration

When you init new animation configuration, you can set duration:

let animationConfig = SPPerspectiveAnimationConfig(duration: 16, distortion: 600, angle: 10, vectorStep: 3.14, shadow: nil)
view.applyPerspective(animationConfig)

If need change duration for default config, using this:

let animationConfig = SPPerspectiveConfig.iOS14WidgetAnimatable
animationConfig.animationDuration = 8
view.applyPerspective(animationConfig)

Perspective

Angle is how much the view will rotate. For change it call angle in config:

animationConfig.angle = 10

Also you can customise distortion of perspective. Using this:

animationConfig.distortionPerspective = 600

Both properties allow you configure transform for your view. If you don't know which values shoud using, check use example app (video preview). With sliders you can customize it in detail.

Shadow

Shadow also using configuration. Static and animation configs contains shadow property.

Blur, Opacity & Color

It simple. For change blur, opacity and color call this in configuration.

animationConfig.shadowConfig?.blurRadius = 5
animationConfig.shadowConfig?.opacity = 0.3
animationConfig.shadowConfig?.color = .black

Translations

Translation help customise position of shadow for any state of transform. For example you can want do more vertical translation for show deep transform.

Transform adaptive for each higlight corner. For example startVerticalOffset using when highlight top-center side. For bottom corners available cornerVerticalOffset. For bottom-center side shoud change maximumVerticalOffset . Horizontal trnalation customising by maximumHorizontalOffset.

animationConfig.shadowConfig?.startVerticalOffset = 8
animationConfig.shadowConfig?.cornerVerticalOffset = 18
animationConfig.shadowConfig?.maximumVerticalOffset = 21
animationConfig.shadowConfig?.maximumHorizontalOffset = 12

For get fine result, you shoud use this rule: startVerticalOffset < cornerVerticalOffset < maximumVerticalOffset. Visual transform available in example app (video preview), with it you get fine values.

Сontribution

My English is very bad. You can see this once you read the documentation. I would really like to have clean and nice documentation. If you see gramatical errors and can help fix the Readme, please contact me [email protected] or make a Pull Request. Thank you in advance!

Other Projects

I love being helpful. Here I have provided a list of libraries that I keep up to date. For see video previews of libraries without install open opensource.ivanvorobei.by website.
I have libraries with native interface and managing permissions. Also available pack of useful extensions for boost your development process.

Russian Community

Подписывайся в телеграмм-канал, если хочешь получать уведомления о новых туториалах.
Со сложными и непонятными задачами помогут в чате.

Видео-туториалы выклыдываю на YouTube:

Tutorials on YouTube

You might also like...
Pulse animation for iOS written with Swift.
Pulse animation for iOS written with Swift.

Pulsator Pulse animation for iOS written with Swift. Great For: Pulses of Bluetooth, BLE, beacons (iBeacon), etc. Map Annotations Installation CocoaPo

Easy animation library on iOS with Swift2
Easy animation library on iOS with Swift2

Cheetah Cheetah is an animation utility on iOS with Swift. Cheetah can animate any properties since Cheetah uses simple CADisplayLink run loop to chan

A radical & elegant animation library for iOS.
A radical & elegant animation library for iOS.

Installation • Usage • Debugging • Animatable Properties • License Dance is a powerful and straightforward animation framework built upon the new UIVi

Pulse animation for iOS

Pulsator Pulse animation for iOS written with Swift. Great For: Pulses of Bluetooth, BLE, beacons (iBeacon), etc. Map Annotations Installation CocoaPo

iOS Component for creating a pulsing animation.

PulsingHalo PulsingHalo has been discontinued, and is no longer being maintained. Please check out Pulsator which is the new version of this written w

Animation library for iOS in Swift
Animation library for iOS in Swift

TweenKit TweenKit is a powerful animation library that allows you to animate (or 'tween') anything. TweenKit's animations are also scrubbable, perfect

This library is for adding animation to iOS tabbar items, which is inherited from UITabBarController.
This library is for adding animation to iOS tabbar items, which is inherited from UITabBarController.

This library is for adding animation to iOS tabbar items, which is inherited from UITabBarController. Installation Just add the Sources folder to your

Awesome IOS Styling with SwiftUI, Animation, Effects, Gesture ⭐️

Awesome SwiftUI Styling with SwiftUI ⭐️ This repository is dedicated to IOS styling using SwiftUI. (often using Other Libraries.) I started collecting

Wave is a spring-based animation engine for iOS that makes it easy to create fluid, interruptible animations that feel great.
Wave is a spring-based animation engine for iOS that makes it easy to create fluid, interruptible animations that feel great.

Wave is a spring-based animation engine for iOS and iPadOS. It makes it easy to create fluid, interactive, and interruptible animations that feel great.

Comments
  • When two views overlap, there seems to be a bug

    When two views overlap, there seems to be a bug

    My code is as followsimage `let bottomView = UIView(frame: CGRect(x: 44, y: 44, width: 200, height: 200)) bottomView.backgroundColor = .red view.addSubview(bottomView)

        // same position, has alpha 0.5
        let topView = UIView(frame: CGRect(x: 44, y: 44, width: 200, height: 200))
        topView.backgroundColor = UIColor(white: 1, alpha: 1)
        view.addSubview(topView)
    
        topView.applyPerspective(.iOS14WidgetAnimatable)`
    

    image

    bug 
    opened by qiuyuliang 5
  • Add missing public initializer for SPPerspectiveShadowConfig

    Add missing public initializer for SPPerspectiveShadowConfig

    Goal

    Add public initializer to SPPerspectiveShadowConfig because currently is is impossible to create a custom configuration for the shadow since the initializer is not exposed publicly and thus leads to an error ('SPPerspectiveShadowConfig' is inaccessible due to 'internal' protection level). That is because Swift does not expose the auto-generated member-wise initializer for structs.

    Source:

    As with the default initializer above, if you want a public structure type to be initializable with a memberwise initializer when used in another module, you must provide a public memberwise initializer yourself as part of the type’s definition.

    From: Swift.org

    opened by niklasamslgruber 1
  • Fix typo ( translation, transform )

    Fix typo ( translation, transform )

    Goal

    Fix minor typo in comments

    • SPPerspective: Create vector for trnaform by corner.
    • Config need for get trnslation values.

    Checklist

    • [x] Testing in iOS
    • [x] Installed correct via Swift Package Manager and Cocoapods
    opened by woookDev 0
Releases(1.4.1)
Owner
Ivan Vorobei
iOS Developer
Ivan Vorobei
Swiftui-animation-observer - Track SwiftUI animation progress and completion via callbacks

SwiftUI Animation Observer Track SwiftUI animation progress and completion via c

Gordan Glavaš 9 Nov 5, 2022
Simple Interface Core Animation. Run type-safe animation sequencially or parallelly

Simple Interface Core Animation Sica can execute various animations sequentially or parallelly. Features Animation with duration and delay parallel /

CATS Open Source Softwares 1k Nov 10, 2022
An experiment for using SwiftUI's custom timing Animation to create an orbital-like animation.

Orbital-SwiftUI-Animation An experiment for using SwiftUI's custom timing curve to create an orbital-like animation. How it looks: How it works: Apply

Mostafa Abdellateef 7 Jan 2, 2023
SwiftUI-Text-Animation-Library - Text animation library for SwiftUI

⚠️ This repository is under construction. SwiftUI Text Animation Library Make yo

null 28 Jan 8, 2023
DynamicBlurView is a dynamic and high performance UIView subclass for Blur.

DynamicBlurView DynamicBlurView is a dynamic and high performance UIView subclass for Blur. Appetize's Demo Since using the CADisplayLink, it is a hig

Kyohei Ito 929 Jan 5, 2023
Fortune spinning wheel library built using SwiftUI, supports dynamic content.

Fortune Wheel Fortune spinning wheel ?? library built using SwiftUI, supports dynamic content. Preview - Spin Wheel ⚙️ CocoaPods Installation FortuneW

Sameer Nawaz 51 Dec 23, 2022
An extensible iOS and OS X animation library, useful for physics-based interactions.

Pop is an extensible animation engine for iOS, tvOS, and OS X. In addition to basic static animations, it supports spring and decay dynamic animations

Meta Archive 19.8k Dec 28, 2022
Swift animation library for iOS, tvOS and macOS.

anim is an animation library written in Swift with a simple, declarative API in mind. // moves box to 100,100 with default settings anim { self.bo

Onur Ersel 555 Dec 12, 2022
A DSL to make animation easy on iOS with Swift.

This project is highly inspired by JHChainableAnimations, If you project is developed with Objective-C, use JHChainableAnimations instead. With DKChai

Draven 1.9k Dec 9, 2022
Gemini is rich scroll based animation framework for iOS, written in Swift.

Overview What is the Gemini? Gemini is rich scroll based animation framework for iOS, written in Swift. You can easily use GeminiCollectionView, which

Shohei Yokoyama 3k Dec 27, 2022