0

Im moving a UIView from its original position as laid out on my XIB/Storyboard using the following: -(void)myMovingViewAction{

[UIView animateWithDuration:.15
                 animations:^{
                     [theView setFrame:CGRectMake(0, 40, theView.frame.size.width, theView.frame.size.height)];
                 }
 ];

}

Problem i have is getting the UIView back to its original postion as laid out on my Storyboard UIViewController/XIB.

I know i could use the same code as above with the original co-ordinates in it, but these co-ordinates are different on different devices. in this example, Constraints are keeping my UIView hugged against the bottom of my UIViewController in its original position.

Is there a way i can send this view back to 'default' position?

Thanks in advance! :)

user1736431
  • 81
  • 1
  • 5

1 Answers1

0

create an instance var theFrame of type CGRect, set it to theView.frame on viewDidAppear. when you want to move it to back to original position, you can do

[UIView animateWithDuration:.15
                 animations:^{
                     [theView setFrame:theFrame];
                 }
 ];

}
Nitin Alabur
  • 5,812
  • 1
  • 34
  • 52