Advertisement
Guest User

Untitled

a guest
Oct 25th, 2014
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. -(void)viewDidLoad{
  2.  
  3. [self setup];
  4. }
  5.  
  6. - (void)setup
  7. {
  8.  
  9. self.dummyView.backgroundColor = [UIColor whiteColor];
  10.  
  11. CGSize size = self.dummyView.bounds.size;(dummy view frame is (0,0,320,568 ))
  12. self.paneState = PaneStateClosed;
  13. self.pane = [[DraggableView alloc] initWithFrame:CGRectMake(0, 568, size.width, size.height)];(//This is my draggable view)
  14. self.pane.backgroundColor = [UIColor grayColor];
  15. self.pane.layer.cornerRadius = 8;
  16. self.pane.delegate = self;
  17. [self.dummyView addSubview:self.pane];
  18.  
  19. self.animator = [[UIDynamicAnimator alloc] initWithReferenceView:self.dummyView];
  20.  
  21. UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTap:)];
  22. [self.dummyView addGestureRecognizer:tapRecognizer];
  23.  
  24. }
  25.  
  26. - (void)animatePaneWithInitialVelocity:(CGPoint)initialVelocity
  27. {
  28. if (!self.paneBehavior) {
  29. PaneBehavior *behavior = [[PaneBehavior alloc] initWithItem:self.pane];
  30. self.paneBehavior = behavior;
  31. }
  32. self.paneBehavior.targetPoint = self.targetPoint;
  33. self.paneBehavior.velocity = initialVelocity;
  34. [self.animator addBehavior:self.paneBehavior];
  35. }
  36.  
  37. - (CGPoint)targetPoint
  38. {
  39. CGSize size = self.dummyView.bounds.size;
  40. return self.paneState == PaneStateClosed > 0 ? CGPointMake(size.width/2, size.height * 1.25) : CGPointMake(size.width/2, size.height/2 + 50);
  41. }
  42.  
  43. - (void)didTap:(UITapGestureRecognizer *)tapRecognizer
  44. {
  45. self.paneState = self.paneState == PaneStateOpen ? PaneStateClosed : PaneStateOpen;
  46. [self animatePaneWithInitialVelocity:self.paneBehavior.velocity];
  47.  
  48. self.dummyView.hidden = YES(//When i set hidden is equal to YES then my animation effect loses.This one line code has problem. How to hide dummyView without losing animation effect?)
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement