Just display the values โ€‹โ€‹of UIInterpolatingMotionEffect?

Here is a puzzle, imagine a typical UIInterpolatingMotionEffect ,,

UIInterpolatingMotionEffect *horizontalMotionEffect =
  [[UIInterpolatingMotionEffect alloc]
    initWithKeyPath:@" .. some property .."
     type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];
horizontalMotionEffect.minimumRelativeValue = @(-50);
horizontalMotionEffect.maximumRelativeValue = @(50);
[someView addMotionEffect:horizontalMotionEffect];

Usually you need to place the property on line 3 - let's say center.x

But - what if I (very simply) want to see the value of UIInterpolatingMotionEffect? A.

(Or I can use it for some other purpose, say.)

Do I really have to subclass CALayer and create a new animated property ?!

It seems incredibly difficult to just access the value. The only trick I could think of was simply to make an invisible look, set it in the center and access the value! Seems silly though.

Any ideas?

+2
source share
1 answer

UIInterpolatingMotionEffect -(NSDictionary *)keyPathsAndRelativeValuesForViewerOffset:(UIOffset)viewerOffset, viewerOffset, , , - , min max.

UILogInterpolatingMotionEffect.h

@interface UILogInterpolatingMotionEffect : UIInterpolatingMotionEffect

@end

UILogInterpolatingMotionEffect.m

@implementation UILogInterpolatingMotionEffect

-(NSDictionary *)keyPathsAndRelativeValuesForViewerOffset:(UIOffset)viewerOffset
{
    NSDictionary *superDictionary = [super keyPathsAndRelativeValuesForViewerOffset:viewerOffset)];
    NSLog(@"%@, %@", NSStringFromUIOffset(viewerOffset), superDictionary);
    return superDictionary;
}

@end

PS: viewerOffset, UIMotionEffect. . UIMotionEffect.

+5

All Articles