Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.07 KB | None | 0 0
  1. float mapNewX = self.mapView.frame.origin.x == 0 ? 375 : 0;
  2. float mapNewWidth = mapNewX == 0 ? self.view.frame.size.width : self.view.frame.size.width - mapNewX;
  3.  
  4. [UIView animateKeyframesWithDuration:0.1 delay:0.0 options:UIViewAnimationCurveEaseOut animations:^
  5. {
  6. CGRect mapViewFrame = self.mapView.frame;
  7. mapViewFrame.origin.x = (mapNewX);
  8. mapViewFrame.size.width = mapNewWidth;
  9. self.mapView.frame = mapViewFrame;
  10. }
  11. completion:^(BOOL finished)
  12. {
  13. NSLog(@"OK");
  14. }];
  15.  
  16. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *mapLeadingSpace;
  17.  
  18. - (void)viewWillAppear:(BOOL)animated
  19. {
  20. [super viewWillAppear:animated];
  21.  
  22. self.mapLeadingSpace.constant = 0; // default is closed
  23. }
  24.  
  25. - (IBAction)toggle:(id)sender
  26. {
  27. self.mapLeadingSpace.constant = self.mapLeadingSpace.constant == 0
  28. ? self.tableView.frame.size.width // opened
  29. : 0; // closed
  30.  
  31. [UIView animateWithDuration:.2 animations:^{
  32. [self.imageView layoutIfNeeded];
  33. }];
  34. }
  35.  
  36. [subview setTranslatesAutoresizingMaskIntoConstraints:NO];
  37. [parentview setTranslatesAutoresizingMaskIntoConstraints:NO];
  38.  
  39. [parentview addSubview:subview];
  40.  
  41. NSDictionary *views = NSDictionaryOfVariableBindings(subview);
  42. [parentview addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[subview]"
  43. options:0
  44. metrics:nil
  45. views:views]];
  46.  
  47. NSArray *firstConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:[subview]"
  48. options:0
  49. metrics:nil
  50. views:views];
  51. [parentview addConstraints:firstConstraints];
  52. [parentview layoutSubtreeIfNeeded];
  53. [parentview removeConstraints:firstConstraints];
  54.  
  55. NSArray *secondConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-100-[subview]-100-|"
  56. options:0
  57. metrics:nil
  58. views:views];
  59. [parentview addConstraints:secondConstraints];
  60.  
  61. subview.superview.wantsLayer = YES;
  62. [NSAnimationContext runAnimationGroup:^(NSAnimationContext* context) {
  63. [context setDuration:.3];
  64. [context setAllowsImplicitAnimation:YES];
  65. [context setTimingFunction: [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];
  66. [subview layoutSubtreeIfNeeded];
  67. } completionHandler:^{
  68. [[self delegate] createOptionMenuForPDFViewWithInvoice:invoice andSuperView:parentview];
  69. }];
  70.  
  71. // update constraints…
  72.  
  73. [UIView animateWithDuration:0.5 animations:^{
  74. [self.view layoutIfNeeded];
  75. }];
  76.  
  77. if ([self respondsToSelector:@selector(edgesForExtendedLayout)]) {
  78. self.edgesForExtendedLayout = UIRectEdgeNone;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement