Reputation: 3931
I'm a bit confused with the difference between a UIViews layer and its frame. From what I understand, a layer is like an image representation of a view. So, say I implement a method like this in a UIView subclass:
-(void)translate
{
CATransform3D translate = CATransform3DIdentity;
translate = CATransform3DTranslate(translate, 20, 0, 0);
[UIView animateWithDuration:2 animations:^{
self.layer.transform = translate;
} completion:^(BOOL finished){
}];
}
So, if I want the view to actually be at that location at the end of the animation, what property to I change? Do I move the frame, and then set the transform to identity?
Upvotes: 1
Views: 469
Reputation: 5656
Each view is backed by a CALayer (as in, each UIView has a CALayer). The UIView adds built-in mechanisms for interaction, among other things.
The frame will automatically be changed if you change the layer, so if you animate on the layer, you don't need to worry about maintaining the view's frame property (that's UIKit's job).
As for animating the layer vs the view itself, Brad Larson has a good explanation:
iOS: Should I Add UIViews or CALayers for animation?
Upvotes: 1