- (void)viewDidLoad {
[super viewDidLoad];
CGPoint frameCenter = self.view.center;
float width = 50.0;
float height = 50.0;
CGRect viewFrame = CGRectMake(frameCenter.x-width,frameCenter.y-height, width*2, height*2);
UIView *myView = [[UIView alloc] initWithFrame:viewFrame];
myView.backgroundColor = [UIColor blueColor];
//create subview
CGRect subViewFrame = CGRectInset(myView.bounds, width/2.0, height/2.0);
UIView *mySubview = [[UIView alloc] initWithFrame:subViewFrame];
mySubview.backgroundColor = [UIColor yellowColor];
//set autoresizing mask
mySubview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[myView addSubview:mySubview];
[[self view] addSubview:myView];
//animate resize
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
viewFrame = CGRectInset(viewFrame, -width, -height);
[myView setFrame:viewFrame];
[UIView commitAnimations];
[mySubview release];
[myView release];
}