is there a possibility to animate an uibutton in this way that a thing or whatever comes out of the background e.g. a wheat ear comes 开发者_开发知识库out of a field.
is this possible?
thanks :)
Unless you want a more complicated animation, you can just create a custom type UIButton (either with IB by changing the type to Custom, or programmatically with UIButton *aButton = [UIButton buttonWithType:UIButtonTypeCustom]
), then set the button's image with [aButton setImage:[UIImage imageNamed:@"wheat_ear" forState:UIControlStateNormal]
.
To move it, just animate its position normally...
[UIView animateWithDuration:0.5 animations:^{aButton.center = newCenter;}];
Or, to provide the illusion of it coming out of the field, animate the bounds of the image so that it starts with the image's width and zero height, and ends with the image's width and height:
CGRect originalFrame = aButton.frame;
aButton.frame = CGRectMake(originalFrame.origin.x, originalFrame.origin.y, originalFrame.size.width, 0);
[UIView animateWithDuration:0.5 animations:^{aButton.frame = originalFrame;}];
精彩评论