I have a super UIView
which has a sub UIView
. The sub UIView
has the UIPanGestureRecognizer
.
I need to move the super UIView
when the user tries to move the subUIView
.
I do not want to set the center as that would give a jerk.
I need to move the super UIView
smoothly when the user tries to move the sub UIView
.Because the super UIView
is moving, the user will get the feeling that he is moving the sub UIView
.
So, I how do I get this done?
You can set the center to avoid jerk use UIView
animation block
[UIView animateWithDuration:0.5
animations:^{
//set center here
}
completion:^(BOOL finished) {
}];
assuming you set the frame of the subUIView
when the gesture recognizer triggers, just move the super view the same amount
subview.frame = CGRectMake(-x,-y,w,h); //move opposite way to superview
[subview superview].frame = CGRectMake(x,y,w,h); //move
edit: misinterpreted what you were trying to accomplish a bit, you would need to move the subview the opposite way to which the superview is moving for the subview to stay in place while the superview moves
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.