Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -(void)viewDidLoad{
- [self setup];
- }
- - (void)setup
- {
- self.dummyView.backgroundColor = [UIColor whiteColor];
- CGSize size = self.dummyView.bounds.size;(dummy view frame is (0,0,320,568 ))
- self.paneState = PaneStateClosed;
- self.pane = [[DraggableView alloc] initWithFrame:CGRectMake(0, 568, size.width, size.height)];(//This is my draggable view)
- self.pane.backgroundColor = [UIColor grayColor];
- self.pane.layer.cornerRadius = 8;
- self.pane.delegate = self;
- [self.dummyView addSubview:self.pane];
- self.animator = [[UIDynamicAnimator alloc] initWithReferenceView:self.dummyView];
- UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTap:)];
- [self.dummyView addGestureRecognizer:tapRecognizer];
- }
- - (void)animatePaneWithInitialVelocity:(CGPoint)initialVelocity
- {
- if (!self.paneBehavior) {
- PaneBehavior *behavior = [[PaneBehavior alloc] initWithItem:self.pane];
- self.paneBehavior = behavior;
- }
- self.paneBehavior.targetPoint = self.targetPoint;
- self.paneBehavior.velocity = initialVelocity;
- [self.animator addBehavior:self.paneBehavior];
- }
- - (CGPoint)targetPoint
- {
- CGSize size = self.dummyView.bounds.size;
- return self.paneState == PaneStateClosed > 0 ? CGPointMake(size.width/2, size.height * 1.25) : CGPointMake(size.width/2, size.height/2 + 50);
- }
- - (void)didTap:(UITapGestureRecognizer *)tapRecognizer
- {
- self.paneState = self.paneState == PaneStateOpen ? PaneStateClosed : PaneStateOpen;
- [self animatePaneWithInitialVelocity:self.paneBehavior.velocity];
- 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?)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement