adali adali - 2 months ago 22
iOS Question

Anyway to animate a UIImageview's contentMode from aspectFill to aspectFit?

[UIView animateWithDuration:30.0f delay:0.0f options:UIViewAnimationOptionCurveEaseInOut animations:^{
v.contentMode = UIViewContentModeScaleAspectFit;
v.frame = v.superview.bounds;
} completion:^(BOOL finished) {
[v removeFromSuperview];
}];


I wanna a UIImageview to resize & change the contentMode, but the code above doesn't work,
it changed the contentMode immediately at the beginning of the animation.

Is there anyway to animate it?

Answer

UIImageView inherits its contentMode property from UIView. It is not one of the properties you can animate. More information can be found in the View Programming Guide.

Comments