michaeljbishop / NGAParallaxMotion

A tiny category on UIView that allows you to set one property: "parallaxIntensity" to achieve a parallax effect with UIMotionEffect
MIT License
641 stars 31 forks source link

Added MWInterpollationMotionEffect #2

Closed Przytua closed 11 years ago

Przytua commented 11 years ago

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.

michaeljbishop commented 11 years ago

Hi Przytua, Sorry for the long delay. I'd like to be able to use your MWInterpollationMotionEffect as a backup on iOS 6 (as you've proposed). Here's what I'd like to propose:

  1. Can you make the API for MWInterpollationMotionEffect identical to UIInterpolatingMotionEffect? I ask because I think MWInterpollationMotionEffect is a really great idea but think it would have better adoption if it didn't present a new api.
  2. In NGAParallaxMotion, the code will determine if its on iOS 7 and if not, will see if the methods in MWInterpollationMotionEffect exist and will use that as a backup. Or if that's not present, it will be disabled.

What do you think?

_ michael

Przytua commented 11 years ago

Hi Michael,

You mut've misunderstood me, the MWInterpollationMotionEffect only adds availability of setting negative values to the parallax effect (which was'nt working with UIInterpollationMotionEffect - you can set negative value but the view doesn't move). But your idea of putting together ios7 and ios6 parallax is great. I have another repo (UIView+MWParallax) in which I have a UIView category similar to this, but working on iOS prior to 7. I will add it here, make it work with only 1 param, and I'll send you another pull request.

Łukasz

michaeljbishop commented 11 years ago

Hi Łukasz,

I'm having trouble reproducing the problem you are describing. Here's what I did and maybe you have done something different. I edited my demo program.

  1. I made a UIImageView as the "background view" of my main view and made it the first subview.
  2. Then, on the UIImageView I set a negative value for parallaxIntensity (-60).
  3. When I ran the program again the image did look recessed behind the screen which suggests to me that it works.

But are you seeing something different?

Przytua commented 11 years ago

I mean that you can set:

minimumRelativeValue = @(-10); maximumRelativeValue = @(10);

and view moves in the direction of device motion, but if you want it to move in opposite way, setting:

minimumRelativeValue = @(10); maximumRelativeValue = @(-10);

isn't working, it just makes the view still. What my MWInterpollationMotionEffect changes is that you set only 1 param, which if set to positive, makes the view move in both directions with the same factor, but if you set negative value, it also moves in both directions with the same factor, but in opposite way. Check in my sample app, the background is moving in opposite way to the labels, because it is set to negative value.

michaeljbishop commented 11 years ago

Hi , I've made a branch of your project to try this myself. It's here:

https://github.com/michaeljbishop/NGAParallaxMotion/tree/UIInterpolatingMotionEffect-test

The project is the same, but I removed MWInterpollationMotionEffect to see if I could reproduce the bug you've been describing. I can't so I think I still don't understand. It looks like the background is recessed behind the screen which is the desired effect.

Can you please try it and tell me if you see something different than your branch?

Please note that I've changed the parallaxIntensity on the background image from -20 to -60 just to increase the effect (but the value is still negative).

Przytua commented 11 years ago

You're right. It's working as it should be. When i was testing it, when I set the maximumRelativeValue as negative, and minimumRelativeValue positive, the view didn't move. Maybe it was a bug in beta or I just did something wrong. So just ignore this pull request and sorry for the confusion :)

michaeljbishop commented 11 years ago

Sounds like you are right, that it could have been a bug that was fixed.

However, if you have a version of the UIInterpolatingMotion effect API that works on iOS6, I'd definitely be interested in bringing that in.

Przytua commented 11 years ago

I have it here: https://github.com/Przytua/UIView-MWParallax but some people are reporting crashes (which are hard to reproduce for me). I need to check it deeply, and i can add it to your NGAParallaxMotion, but i have a lot of work this week, so I'll probably do this next week.