Guest User

Untitled

a guest
Jul 18th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. if (!CGRectIsNull(rectIntersection)) {
  2. CGRect newFrame = CGRectOffset (rectIntersection, 0, -2);
  3. [backgroundView setFrame:newFrame];
  4. } else{
  5. [viewsUpdater invalidate];
  6. viewsUpdater = nil;
  7. }
  8.  
  9. CGRect mainViewFrame = [mainView frame];
  10. if (!CGRectContainsRect(mainViewFrame, backgroundFrame)) {
  11. CGRect newMainViewFrame = CGRectMake(0,
  12. 0,
  13. mainViewFrame.size.width,
  14. (mainViewFrame.size.height + 2));
  15. [mainView setFrame:newMainViewFrame];
  16. }
  17.  
  18. if (!CGRectIsNull(rectIntersection)) {
  19. // here you set the wrong frame
  20. //CGRect newFrame = CGRectOffset (rectIntersection, 0, -2);
  21. CGRect newFrame = CGRectOffset (backgroundView.frame, 0, -2);
  22. [backgroundView setFrame:newFrame];
  23. } else{
  24. [viewsUpdater invalidate];
  25. viewsUpdater = nil;
  26. }
  27.  
  28. // eventually a control action method, pass nil for direct call
  29. -(void)performBackgroundViewAnimation:(id)sender {
  30. // first, double the mainView's frame height
  31. CGFrame newFrame = CGRectMake(mainView.frame.origin.x,
  32. mainView.frame.origin.y,
  33. mainView.frame.size.width,
  34. mainView.frame.size.height*2);
  35. // then get the backgroundView's destination rect
  36. CGFrame newBVFrame = CGRectOffset(backgroundView.frame,
  37. 0,
  38. -(backgroundView.frame.size.height));
  39. // run the animation
  40. [UIView animateWithDuration:1.0
  41. animations:^{
  42. mainView.frame = newFrame;
  43. backgroundView.frame = newBVFrame;
  44. }
  45. ];
  46. }
Add Comment
Please, Sign In to add comment