问题传送
I want, that searchField deformation to targetFrame.
#1 This not result:
- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)bar
{
UITextField *searchField = [bar valueForKey:@"_searchField"];
CGRect targetFrame = CGRectMake(-50, 0, 200, 30);
searchField.frame = targetFrame; //not result
return YES;
}
#2 Incorrect, but transform:
- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)bar
{
UITextField *searchField = [bar valueForKey:@"_searchField"];
searchField.frame = CGRectMake (10, 0, 200, 50); //must differ from CGRectZero
[UIView animateWithDuration: 3.0
animations: ^{
CGRect targetFrame = CGRectMake(-50, 0, 200, 30);
searchField.frame = targetFrame;
}];
return YES;
}
Then using #2, searchField start animation, but to default size (not to targetFrame).
I want, that searchField transform to targetFrame.
#3 solution
[UIView animateWithDuration:3.0
delay:0
options:UIViewAnimationOptionLayoutSubviews
animations:^{
CGRect targetFrame = CGRectMake(-50, 0, 200, 30);
searchField.frame = targetFrame;
}
completion:^(BOOL finished) {
}];
网友评论