PMTweenUnit Class Reference
| Inherits from | NSObject |
| Conforms to | PMTweenTempoDelegate PMTweening |
| Declared in | PMTweenUnit.h PMTweenUnit.m |
Overview
PMTweenUnit handles a single tween operation on an NSValue property, interpolating between specified starting and ending values.
Tasks
Creating an Instance
-
– initWithProperty:startingValue:endingValue:duration:options:easingBlock: -
– initWithObject:propertyKeyPath:startingValue:endingValue:duration:options:easingBlock:
Setting Up a Tween
-
delayproperty -
durationproperty -
repeatingproperty -
numberOfRepeatsproperty -
additiveproperty -
structValueUpdaterproperty
Easing Blocks
-
easingBlockproperty -
reverseEasingBlockproperty
Tween State
-
targetPropertyproperty -
targetObjectproperty -
propertyKeyPathproperty -
operationIDproperty -
tweenStateproperty -
tweenDirectionproperty -
startingValueproperty -
currentValueproperty -
endingValueproperty -
tweenProgressproperty -
cycleProgressproperty -
cyclesCompletedCountproperty
Notification Blocks
-
startBlockproperty -
stopBlockproperty -
updateBlockproperty -
repeatCycleBlockproperty -
reverseBlockproperty -
pauseBlockproperty -
resumeBlockproperty -
completeBlockproperty
Controlling a Tween
Properties
additive
A Boolean which determines whether this tween should change its property value additively. Additive animation allows multiple tweens to produce a compound effect, instead of overwriting each other as they update the same property. Additive animation is now the default behavior for tweening animations in iOS 8, and is great for making user interface animations fluid and responsive.
@property (nonatomic, assign) BOOL additiveDiscussion
@remarks The startingValue property is ignored for additive animations, and will instead combine with the current value of the property being tweened. Please be aware that because of the composite nature of additive animations, values can temporarily tween past the specified endingValue. This can have unintended consequences if the property you are tweening is clamped to a limited range of values. Also note that additive animations may not work well with complex tweens using sequences, reversing, or repeating, and will not work with other tweens that are not using the additive mode. Because of these caveats, the default value is NO.
Declared In
PMTweenUnit.hcompleteBlock
This notification block is executed when a tween operation has completed (or when all tween cycles have completed, if repeating is set to YES).
@property (nonatomic, copy) PMTweenDidCompleteBlock completeBlockDeclared In
PMTweenUnit.hcurrentValue
The current value of the tween operation. (read-only)
@property (readonly, nonatomic, assign) double currentValueDiscussion
@remarks Note that for non-numeric properties like structs this may affect multiple values, such as the x and y properties of CGPoint.
See Also
@property startingValue, endingvalue
Declared In
PMTweenUnit.hcycleProgress
A float value between 0.0 and 1.0, which represents the current progress of a tween cycle. (read-only)
@property (readonly, nonatomic, assign) CGFloat cycleProgressDiscussion
@remarks This progress could represent one tween or two, depending on whether reversing is set to YES.
Declared In
PMTweenUnit.hcyclesCompletedCount
The amount of completed tween cycles. (read-only)
@property (readonly, nonatomic, assign) NSUInteger cyclesCompletedCountDiscussion
@remarks A cycle represents the total length of tweening operation. If reversing is set to YES, a cycle comprises two separate tweens; otherwise a cycle is the length of one tween.
Declared In
PMTweenUnit.hdelay
The delay, in seconds, before a tween operation begins.
@property (nonatomic, assign) NSTimeInterval delayDiscussion
Warning: Setting this parameter after a tween operation has begun has no effect.
Declared In
PMTweenUnit.hduration
The duration of a tween operation, in seconds. (read-only)
@property (nonatomic, assign) NSTimeInterval durationDiscussion
@remarks If reversing is set to YES, the duration of a total tween cycle will be twice this amount as there will be two separate tween operations (forwards and back).
Warning: Do not set this parameter while a tween operation is in progress.
Declared In
PMTweenUnit.heasingBlock
A PMTweenEasingBlock block which performs easing calculations for the tweening operation.
@property (nonatomic, copy) PMTweenEasingBlock easingBlockSee Also
Declared In
PMTweenUnit.hendingValue
The ending value of the tween operation.
@property (nonatomic, assign) double endingValueDiscussion
@remarks Note that for non-numeric properties like structs this may affect multiple values, such as the x and y properties of CGPoint.
Declared In
PMTweenUnit.hnumberOfRepeats
The number of tween cycle operations to repeat.
@property (nonatomic, assign) NSUInteger numberOfRepeatsDiscussion
@remarks This property is only used when repeating is set to YES. The default value is 0.
See Also
Declared In
PMTweenUnit.hoperationID
An operation ID is assigned to a PMTweenUnit when it is tweening an object’s property (via initWithObject…) and its tween operation is currently in progress. (read-only)
@property (readonly, nonatomic, assign) NSUInteger operationIDDiscussion
@remarks This value returns 0 if no ID is currently assigned.
Declared In
PMTweenUnit.hpauseBlock
This notification block is executed when calling the pauseTween method on this instance causes a tween operation to pause.
@property (nonatomic, copy) PMTweenDidPauseBlock pauseBlockSee Also
Declared In
PMTweenUnit.hpropertyKeyPath
Key path for property on target. Only used when class is created with initWithObject.
@property (readonly, nonatomic, copy) NSString *propertyKeyPathDeclared In
PMTweenUnit.hrepeatCycleBlock
This notification block is executed when a tween cycle has repeated.
@property (nonatomic, copy) PMTweenDidRepeatBlock repeatCycleBlockDeclared In
PMTweenUnit.hrepeating
A Boolean which determines whether a tween operation should repeat.
@property (nonatomic, assign) BOOL repeatingDiscussion
@remarks When set to YES, the tween operation repeats for the number of times specified by the numberOfRepeats property. The default value is NO.
See Also
Declared In
PMTweenUnit.hresumeBlock
This notification block is executed when calling the resumeTween method on this instance causes a tween operation to resume.
@property (nonatomic, copy) PMTweenDidResumeBlock resumeBlockSee Also
Declared In
PMTweenUnit.hreverseBlock
This notification block is executed when this instance’s tweenDirection property changes to PMTweenDirectionReverse.
@property (nonatomic, copy) PMTweenDidReverseBlock reverseBlockSee Also
@property tweenDirection, reversing
Declared In
PMTweenUnit.hreverseEasingBlock
An optional PMTweenEasingBlock block which performs easing calculations for the tweening operation while reversing.
@property (nonatomic, copy) PMTweenEasingBlock reverseEasingBlockDiscussion
@remarks If not defined, the easing block defined by the easingBlock property is used during reversing tweens.
See Also
Declared In
PMTweenUnit.hstartBlock
This notification block is executed when calling the startTween method on this instance causes a tween operation to start.
@property (nonatomic, copy) PMTweenDidStartBlock startBlockSee Also
Declared In
PMTweenUnit.hstartingValue
The starting value of the tween operation.
@property (nonatomic, assign) double startingValueDiscussion
@remarks Note that for non-numeric properties like structs this may affect multiple values, such as the x and y properties of CGPoint.
See Also
@property currentValue, endingvalue
Declared In
PMTweenUnit.hstopBlock
This notification block is executed when calling the stopTween method on this instance causes a tween operation to stop.
@property (nonatomic, copy) PMTweenDidStopBlock stopBlockSee Also
Declared In
PMTweenUnit.hstructValueUpdater
An object conforming to the PMTweenObjectUpdating protocol which handles the updating of properties on objects and structs.
@property (nonatomic, strong) NSObject<PMTweenObjectUpdating> *structValueUpdaterDiscussion
@remarks By default, PMTweenUnit will assign an instance of PMTweenObjectUpdater to this property, but you can override this with your own custom classes if, for instance, you need to tween a value in an object or struct which PMTweenObjectUpdater doesn’t handle.
Declared In
PMTweenUnit.htargetObject
The target object whose property should be tweened, applicable if this instance was initiated with the initWithProperty:… method.
@property (readonly, nonatomic, strong) NSObject *targetObjectDeclared In
PMTweenUnit.htargetProperty
The property to be tweened.
@property (readonly, nonatomic, strong) NSObject *targetPropertyDeclared In
PMTweenUnit.htweenDirection
A PMTweenDirection enum which represents the current direction of the tween operation. (read-only)
@property (readonly, nonatomic, assign) PMTweenDirection tweenDirectionDeclared In
PMTweenUnit.htweenProgress
A float value between 0.0 and 1.0, which represents the current progress of a tween operation between two values. (read-only)
@property (readonly, nonatomic, assign) CGFloat tweenProgressDeclared In
PMTweenUnit.htweenState
A PMTweenState enum which represents the current state of the tween operation. (read-only)
@property (readonly, nonatomic, assign) PMTweenState tweenStateDeclared In
PMTweenUnit.hupdateBlock
This notification block is executed when the updateWithTimeInterval:currentTime: method is called on this instance while this instance’s tweenState is PMTweenStateTweening.
@property (nonatomic, copy) PMTweenDidUpdateBlock updateBlockDeclared In
PMTweenUnit.hInstance Methods
initWithObject:propertyKeyPath:startingValue:endingValue:duration:options:easingBlock:
Initalizes a new PMTweenUnit object, passing in a target object, its property, and values for the tween operation.
- (instancetype)initWithObject:(NSObject *)object propertyKeyPath:(NSString *)propertyKeyPath startingValue:(double)startingValue endingValue:(double)endingValue duration:(NSTimeInterval)duration options:(PMTweenOptions)options easingBlock:(PMTweenEasingBlock)easingBlockParameters
- object
An object whose property should be tweened.
- propertyKeyPath
A string keyPath that points to a NSValue property of the target object to be tweened. Supported properties include several NSValue-encoded structs such as NSNumber, CGPoint, CGSize, CGRect, CGAffineTransform, and CATransform3D.
- startingValue
The property’s starting value for the tween operation.
- endingValue
The property’s ending value for the tween operation.
- duration
The duration of the tween.
- options
A bitmask of
PMTweenOptionsconfiguration values. Defaults toPMTweenOptionNone.
- easingBlock
An optional
PMTweenEasingBlockblock which performs easing calculations.
Return Value
A new instance of this class.
@remarks If you need to update the property of an object such as a UIView, use this method. PMTweenUnit will handle updating the object’s property automatically if you have provided a valid keyPath to the property. For a keyPath to be valid, all objects or NSValue types must be supported. By supplying a custom class to structValueUpdater, you can handle structs that PMTweenUnit doesn’t support by default.
See Also
Declared In
PMTweenUnit.hinitWithProperty:startingValue:endingValue:duration:options:easingBlock:
Initializes a new PMTweenUnit object, passing in a property and values for the tween operation.
- (instancetype)initWithProperty:(NSValue *)property startingValue:(double)startingValue endingValue:(double)endingValue duration:(NSTimeInterval)duration options:(PMTweenOptions)options easingBlock:(PMTweenEasingBlock)easingBlockParameters
- property
An NSValue property to be tweened. Supported properties include several NSValue-encoded structs such as NSNumber, CGPoint, CGSize, CGRect, CGAffineTransform, and CATransform3D.
- startingValue
The property’s starting value for the tween operation.
- endingValue
The property’s ending value for the tween operation.
- duration
The duration of the tween.
- options
A bitmask of
PMTweenOptionsconfiguration values. Defaults toPMTweenOptionNone.
- easingBlock
An optional
PMTweenEasingBlockblock which performs easing calculations.
Return Value
A new instance of this class.
@remarks If you need to tween an NSValue directly, without needing to update an object such as a UIView instance, using this method is adequate.
Declared In
PMTweenUnit.hisReversing
A Boolean which determines whether a tween operation, when it has tweened to the ending value, should tween from the ending value back to the starting value.
- (BOOL)isReversingDiscussion
@remarks When set to YES, the tween plays in reverse after completing a forward tween. In this state, a tween cycle represents the combination of the forward and back tweens. The default value is NO.
Declared In
PMTweening.hpauseTween
Pauses a tween that is currently tweening. (required)
- (void)pauseTweenDiscussion
@remarks When this method is called, a tween should only enter a paused state if it is currently tweening.
Declared In
PMTweening.hresumeTween
Resumes a tween that is currently paused. (required)
- (void)resumeTweenDiscussion
@remarks When this method is called, a tween should only resume tweening if it is currently paused.
Declared In
PMTweening.hsetReversing:
A Boolean which determines whether a tween operation, when it has tweened to the ending value, should tween from the ending value back to the starting value.
- (void)setReversing:(BOOL)reversingDiscussion
@remarks When set to YES, the tween plays in reverse after completing a forward tween. In this state, a tween cycle represents the combination of the forward and back tweens. The default value is NO.
Declared In
PMTweening.hsetTempo:
A concrete PMTweenTempo subclass that provides an update “beat” while a tween operation occurs.
- (void)setTempo:(PMTweenTempo *)tempoDiscussion
@remarks While you don’t have to implement PMTweenTempo for your own class updating, other tween collection classes like PMTweenGroup will try to remove any tempos of tween objects added to them.
Declared In
PMTweening.hstartTween
Starts a tween that is currently stopped. (required)
- (void)startTweenDiscussion
@remarks When this method is called, a tween should only start tweening if it is stopped.
Declared In
PMTweening.hstopTween
Stops a tween that is currently tweening. (required)
- (void)stopTweenDiscussion
@remarks When this method is called, a tween should only enter a stopped state if it currently tweening.
Declared In
PMTweening.htempo
A concrete PMTweenTempo subclass that provides an update “beat” while a tween operation occurs.
- (PMTweenTempo *)tempoDiscussion
@remarks While you don’t have to implement PMTweenTempo for your own class updating, other tween collection classes like PMTweenGroup will try to remove any tempos of tween objects added to them.
Declared In
PMTweening.htempoBeatWithTimestamp:
Sends an update beat that should prompt tweening classes to recalculate tween values.
- (void)tempoBeatWithTimestamp:(NSTimeInterval)timestampParameters
- timestamp
A timestamp with the current time, by which tween classes can calculate new tween values.
Declared In
PMTweenTempo.h