How to add custom animatable property to UIImageView's subclass?
I have the class that I subclassed from UIImageView. The instance of this class is then added as a subview to the my application's root class. Now, I can animate it's properties, for example, setFrame:
[UIView beginAnimations:nil context:nil];
...
[myImageView setFrame:someFrameCreatedInCode];
...
[UIView commitAnimations];
This takes the current frame as the initial state and interpolates imageview animation (it simply moves from the left to the right). This part works fine.
What I would like to do next is I want to add a property to my class, say, of integer type. And I want this propert开发者_JS百科y to cpecify the image number (it's name is formatted) and make frame based animation later. It seems to be a nice way to create animation because I can specify the "curve" to affect the animation timing:
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
How to implement my own property which is possible to animate?
Thanks in advance!
Update: In case someone will need this I found these tutorials in the Internet: blog post, sample.
You'd probably want to use the UIView animations together with the UIImageView animation images.
If you use a code like this:
colors = [[NSArray alloc] initWithObjects:[UIImage imageNamed:@"red_select1.png"],
[UIImage imageNamed:@"red_select2.png"],
[UIImage imageNamed:@"red_select3.png"],
[UIImage imageNamed:@"red_select4.png"],
[UIImage imageNamed:@"red_select5.png"],
[UIImage imageNamed:@"red_select6.png"],
[UIImage imageNamed:@"red_select7.png"],
[UIImage imageNamed:@"red_select8.png"],nil];
animationView = [[UIImageView alloc] initWithFrame:rect];
animationView.animationImages = colors;
animationView.animationDuration = 1.0;
animationView.animationRepeatCount = 0; // loop
[animationView startAnimating];
I think the only problem would be synchronizing the two animations ...
精彩评论