A tiny category on UIView that allows you to set one property: "parallaxIntensity" to achieve a parallax effect with UIMotionEffect

Overview

NGAParallaxMotion

A tiny category on UIView that allows you to set one property: parallaxIntensity to achieve a parallax effect with UIMotionEffect.

Show the parallax effect in one line

theView.parallaxIntensity = 10;

Positive values make the view appear to extend from the screen. Negative values make the view appear to recess behind the screen.

Interface Builder

Additionally, you can set this property within Interface Builder by editing the "User Defined Runtime Attributes" and adding:

KeyPath           |  Type  | Value
----------------------------------------------
parallaxIntensity | Number |  your depth value

Interface Builder

Examples

On

Off

License

This code is under the MIT license.

Release Notes

1.1

  • Added new direction constraints (Thanks @arunaharsa!)

1.0

  • Initial Release
Comments
  • Cannot run in iOS 6 Simulator

    Cannot run in iOS 6 Simulator

    I assumed that this category would degrade more gracefully if running on iOS 6, but I'm unable to run at all. I'm getting the following error:

    dyld: Symbol not found: OBJC_CLASS$_UIInterpolatingMotionEffect Referenced from: /Users/RichardGuy/Library/Application Support/iPhone Simulator/6.0/Applications/19E194FD-988A-4499-9EB1-A559989359C9/Nibblr.app/Nibblr Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk/System/Library/Frameworks/UIKit.framework/UIKit in /Users/RichardGuy/Library/Application Support/iPhone Simulator/6.0/Applications/19E194FD-988A-4499-9EB1-A559989359C9/Nibblr.app/Nibblr (lldb)

    opened by objectmethod 22
  • Added MWInterpollationMotionEffect

    Added MWInterpollationMotionEffect

    Hi,

    I've added my MWInterpollationMotionEffect to your category, it can be set with positive and also negative values, so in the demo which I've updated, the background is moving in opposite direction to the labels.

    opened by Przytua 8
  • nga_parallaxMotionEffectGroup getter responsible for instantiation

    nga_parallaxMotionEffectGroup getter responsible for instantiation

    Hello, this is a great category, thanks for releasing :smile_cat:

    I thought it would be cleaner if the getter function was responsible for ensuring a valid UIMotionEffectGroup is returned. Open to feedback if this pull req doesn't meet your standards.

    opened by zmcartor 5
  • removing strong references from project example

    removing strong references from project example

    strong references from a view to its subviews causes a retain cycle @see https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmPractical.html @see http://www.cocoawithlove.com/2009/07/rules-to-avoid-retain-cycles.html

    opened by riosc 0
  • Stop / Start effect feature

    Stop / Start effect feature

    Currently the parallax effect is stopped by setting the intensity at a 0.0 value. I think this should be great to add start/stop command. Moreover it solve in an elegant way the mistake describe hereafter.

    Test for intensity is highly incorrect as it use equality between float value: chances are great that the condition will never be true.

    if (parallaxDepth == 0.0)
    

    In such case the usage is to use a delta value and change the test to:

    if (parallaxDepth < delta)
    

    As Objective-C is not my main language maybe there is no problem at all to use the equality test on float type. But teachers and professional experience show me this was wrong.

    Finally, thank for this useful and pretty piece of code !

    opened by ghost 1
  • `parallaxIntensity` as a name could use improvement

    `parallaxIntensity` as a name could use improvement

    "Intensity" as a name is a bit vague and it's not clear if an "intensity" can be negative ( though the value of this variable certainly can be).

    Suggestions:

    • parallaxDisplacement
    • parallaxAmount
    • parallaxOffset
    • parallaxAdjustment
    • parallaxLevel
    • parallaxPlane

    I'm open to suggestions.

    opened by michaeljbishop 3
Owner
Michael Bishop
Michael Bishop
A collection of Swift Property Wrappers (formerly "Property Delegates")

?? ?? Burritos A collection of well tested Swift Property Wrappers. @AtomicWrite @Clamping @Copying @DefaultValue @DynamicUIColor @EnvironmentVariable

Guillermo Muntaner 1.3k Dec 26, 2022
Custom UIView class that hosts an array of UIbuttons that have an 'underline' UIView beneath them which moves from button to button when the user presses on them.

Swift-Underlined-Button-Bar Custom UIView class that hosts an array of UIbuttons that have an 'underline' UIView beneath them which moves from button

Justin Cook 3 Aug 4, 2022
This library allows you to make any UIView tap-able like a UIButton.

UIView-TapListnerCallback Example To run the example project, clone the repo, and run pod install from the Example directory first. Installation UIVie

wajeehulhassan 8 May 13, 2022
Tiny Swift DSL for Autolayout

SwiftAutoLayout SwiftAutoLayout is a tiny DSL for Autolayout intended to provide a more declarative way to express layout constraints. Here's a quick

Indragie Karunaratne 657 Sep 18, 2022
In SwiftUI, a property-wrapper provides velocity in pt/s from gesture

swiftui-GestureVelocity In SwiftUI, a property-wrapper provides velocity in pt/s from gesture Instructions @GestureVelocity private var velocity: CGVe

Hiroshi Kimura 9 Oct 3, 2022
Using the UIKitChain framework, You can create a UIKit component in one line of code.

Using the UIKitChain framework, You can create a UIKit component in one line of code. Installation CocoaPods CocoaPods is a dependency manager for Coc

Malith Nadeeshan 1 Sep 1, 2022
A Demo for Shimmer Effect with two methods

ShimmerDemo A Demo for Shimmer Effect with two methods Use Blend Mode + CAGradie

SketchK 9 Feb 9, 2022
Powerful autolayout framework, that can manage UIView(NSView), CALayer and not rendered views. Not Apple Autolayout wrapper. Provides placeholders. Linux support.

CGLayout Powerful autolayout framework, that can manage UIView(NSView), CALayer and not rendered views. Has cross-hierarchy coordinate space. Implemen

Koryttsev Denis 45 Jun 28, 2022
UIView extension that adds dragging capabilities

YiViewDrag Installation YiViewDrag is available through CocoaPods. To install it, simply add the following line to your Podfile: pod 'YiViewDrag' Usag

coderyi 1 Jan 20, 2022
FlightLayout is a light weight, and easy to learn layout framework as an extension of the UIView.

FlightLayout Introduction FlightLayout is a light weight, and easy to learn layout framework as an extension of the UIView. Functionally, it lives som

Anton 23 Apr 21, 2022
Demo App for Picture-in-Picture of Arbitrary UIView in iOS

> 日本語 UIPiPDemo This is a demo app for displaying an arbitrary UIView in iOS using picture-in-picture. It can be used to display information that chan

Akihiro Urushihara 61 Sep 26, 2022
(Swift) iOS UIView layout reimagined

<UIViewprint/> iOS view layout completely reimagined Blueprint /ˈbluːˌprɪnt/ : a detailed outline or plan of action: a blueprint for success. class Vi

Alex Winston 8 Aug 26, 2022
UIView based progress bar that shows a progress based on duration in seconds

DurationProgressBar Create a progress bar based on a duration in seconds. The view is fully customisable. Install Add this repository to your swift pa

Cem Olcay 2 May 21, 2022
NStack is a SwiftUI view that allows you to hoist navigation state into a Coordinator

An NStack allows you to manage SwiftUI navigation state with a single stack property. This makes it easy to hoist that state into a high-level view, such as a coordinator. The coordinator pattern allows you to write isolated views that have zero knowledge of their context within the navigation flow of an app.

John Patrick Morgan 469 Dec 27, 2022
Flixtor-iOS - iOS streaming app inspired by Netflix that allows you to watch any film and series

Flixtor-iOS iOS streaming app inspired by Netflix that allows you to watch any f

Kevin Liu 0 Jan 14, 2022
📱AutoLayout can be set differently for each device

DeviceLayout DeviceLayout is a Swift framework that lets you set Auto Layout constraints's differently for each device Using only IBInspector of Xcode

Cruz 171 Oct 11, 2022
A set of libraries used for parsing representations of Swift Packages similar to how SwiftPM itself works

A set of libraries used for parsing representations of Swift Packages similar to how SwiftPM itself works, but also supporting Xcode specific features (such as Swift Playground Apps).

Liam Nichols 0 Jan 8, 2022
A Set of Tools To Extend UIKit (Classic iOS Framework)

RVS_UIKit_Toolbox A set of basic UIKit tools, for Swift iOS app development. Overview This package offers a few extensions of standard UIKit classes,

The Great Rift Valley Software Company 2 Jul 8, 2022
Auto Layout (and manual layout) in one line.

Auto Layout (and manual layout) in one line. Quick Look view.bb.centerX().below(view2).size(100) It’s equivalent to iOS 9 API: view.centerXAnchor.cons

Javier Zhang 74 Oct 19, 2022