I am not able to expand a UITable from a corner.
This is what I do:
tableAccounts = [[UITableView alloc] initWithFrame:CGRectMake(0, 71, 0,0)];
[self.view addSubview:tableAccounts];
[UIView beginAnimations:@"tableAppearing" context:nil开发者_StackOverflow中文版];
[UIView setAnimationDuration:3.0f];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
tableAccounts.frame = CGRectMake(0, 71, 320, 332);
tableAccounts.backgroundColor = [UIColor redColor];
[UIView commitAnimations];
I can see the table appearing from the top left corner, but not expanding! I mean that the table never changes its size, its always the same size and it is appearing. I want the same effect but starting with a tiny table, and being bigger.
It is possible?
You should be able to do that by applying a scale transform to the tableview and moving it from the corner. The following should grow from the bottom right corner.
CGRect frame = self.view.frame;
int width = CGRectGetWidth(frame);
int height = CGRectGetHeight(frame);
// Make the frame the size you want in the end and place it centered on the corner.
CGRect startTvFrame = CGRectMake(width / 2, height / 2, width, height);
UITableView *tableView = [[UITableView alloc]initWithFrame:startTvFrame];
// Scale the view so that it starts out small
CGAffineTransform t = CGAffineTransformMakeScale(.001, .001);
tableView.transform = t;
[self.view addSubview:tableView];
// Animations
[UIView animateWithDuration:3.0f
delay:0.0f
options:UIViewAnimationCurveLinear
animations:^{
// Reset the scale
tableView.transform = CGAffineTransformMakeScale(1, 1);
// Position the tableview
CGRect tvFrame = tableView.frame;
tvFrame.origin.x = 0;
tvFrame.origin.y = 0;
tableView.frame = tvFrame;
}
completion:nil];
[tableView release];
精彩评论