my view hierachy is following:
BigView
- UIScrollView
- View 1
- View 2
- View 3
- UIView
- UIButton
now i want, that when i pres开发者_JAVA技巧s the UIButton, the BigView (which includes the button as well) moves 100px to the top (so parts of the BigView aren't visible any longer) and another UIView gets visible at the free space under the BigView.
You get the problem? :)
How can I achieve this?
Thanks in advance!
Just do a UIView animation in the method you call when the button is clicked:
[UIView beginAnimations:@"MoveView" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDuration:0.5f];
self.BigView.frame = CGRectMake(newXPoistion, newYPosistion, samewidth, sameheight);
[UIView commitAnimations];
That will animate the bigview to the new cooridinates you give and should move everything within that view aswell
If you want an instant move (without animation) you can do it like this:
CGRect rect = someView.frame;
self.someView.frame = CGRectMake(0, 0, rect.size.width, rect.size.height);
Swift 3
let rect = someView.frame
self.view1.frame = CGRect(x: view1.frame.midX, y: 400, width: rect.width, height: rect.height)
// Or
rectHeigh = someView.frame.height
rectWidth = someView.frame.width
view1.frame = CGRect(x: view1.frame.midX, y: 400, width: rectWidth, height: rectHeigh)
精彩评论