I need to set the position of UIView. The code below shows how I do it. But it does not work. How do I do this?
- (void)viewDidLoad
{
[super viewDidLoad];
CGRect frame = myview.frame;
frame.origin.x = myview.frame.origin.x;
frame.origin.y = 0;
myview.frame = frame;
NSLog(@"%d", frame.origin.y );
}
Try to do this in viewDidAppear method,it works for me.
Make sure that your OUTLET is connected to your view in the nib file.
UIView's have a center property..if you want to change the position then just use that... rather to resize whole view
Hope it helps you.
Move view/ change the position of view with animation
if you want to change the position of View as you want then just use following lines of code :
.h file :
.m file :
Note : To call above method anywhere just do like it , As per your requirement i.e. how to move view/ change the position of view with animation