I am trying to convert a UISearchBar like in Mobile Safari: tap the search field and it grows when the location field is compressed.
My current animation, to change the width and position of the search field, only animates the position: before it moves to the right place, it just jumps out to the desired width. Here is my code:
[UIView beginAnimations:@"searchGrowUp" context:nil]; [UIView setAnimationCurve:UIViewAnimationCurveEaseIn]; [UIView setAnimationDuration:0.5f]; [UIView setAnimationDelegate:self]; CGFloat findFieldWidth = findField.frame.size.width; CGFloat urlFieldWidth = urlField.frame.size.width; CGRect findFieldFrame = findField.frame; CGRect urlFieldFrame = urlField.frame; findFieldFrame.origin.x = findFieldFrame.origin.x - 150.0f; findFieldFrame.size.width = findFieldWidth + 150.0f; urlFieldFrame.size.width = urlFieldWidth - 150.0f; urlField.frame = urlFieldFrame; findField.frame = findFieldFrame; [UIView commitAnimations];
I modified this code a bit to introduce it here, but I hope this makes sense.
Any guesses as to why this is happening will be appreciated!
Cheers, Aaron.
cocoa-touch core-animation uiview
Aaron vegh
source share