I have this subview I want to add to my main view, but make it expand from the origin. I read some of the Apple documentation but I don\'t understand where I am making mistake.
Try using a block it will be more clear.
// First create the view if you haven't already
UIView *myView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 100.0f, 100.0f)];
// Add it as a subview.
[myViewController.view addSubview:myView];
CGRect newFrameOfMyView = CGRectMake(0.0f, 0.0f, 200.0f, 200.0f);
/*
* Alternatively you could just set the width/height or whatever you'd like with this:
* CGRect newFrameOfMyView = myView.frame;
* newFrameOfMyView.size.height = 200.0f;
* newFrameOfMyView.size.width = 200.0f;
*/
[UIView animateWithDuration:0.3f
animations:^{
myView.frame = newFrameOfMyView;
}
completion:^(BOOL finished){
NSLog( @"woo! Finished animating the frame of myView!" );
}];