Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float mapNewX = self.mapView.frame.origin.x == 0 ? 375 : 0;
- float mapNewWidth = mapNewX == 0 ? self.view.frame.size.width : self.view.frame.size.width - mapNewX;
- [UIView animateKeyframesWithDuration:0.1 delay:0.0 options:UIViewAnimationCurveEaseOut animations:^
- {
- CGRect mapViewFrame = self.mapView.frame;
- mapViewFrame.origin.x = (mapNewX);
- mapViewFrame.size.width = mapNewWidth;
- self.mapView.frame = mapViewFrame;
- }
- completion:^(BOOL finished)
- {
- NSLog(@"OK");
- }];
- @property (weak, nonatomic) IBOutlet NSLayoutConstraint *mapLeadingSpace;
- - (void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- self.mapLeadingSpace.constant = 0; // default is closed
- }
- - (IBAction)toggle:(id)sender
- {
- self.mapLeadingSpace.constant = self.mapLeadingSpace.constant == 0
- ? self.tableView.frame.size.width // opened
- : 0; // closed
- [UIView animateWithDuration:.2 animations:^{
- [self.imageView layoutIfNeeded];
- }];
- }
- [subview setTranslatesAutoresizingMaskIntoConstraints:NO];
- [parentview setTranslatesAutoresizingMaskIntoConstraints:NO];
- [parentview addSubview:subview];
- NSDictionary *views = NSDictionaryOfVariableBindings(subview);
- [parentview addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[subview]"
- options:0
- metrics:nil
- views:views]];
- NSArray *firstConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:[subview]"
- options:0
- metrics:nil
- views:views];
- [parentview addConstraints:firstConstraints];
- [parentview layoutSubtreeIfNeeded];
- [parentview removeConstraints:firstConstraints];
- NSArray *secondConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-100-[subview]-100-|"
- options:0
- metrics:nil
- views:views];
- [parentview addConstraints:secondConstraints];
- subview.superview.wantsLayer = YES;
- [NSAnimationContext runAnimationGroup:^(NSAnimationContext* context) {
- [context setDuration:.3];
- [context setAllowsImplicitAnimation:YES];
- [context setTimingFunction: [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];
- [subview layoutSubtreeIfNeeded];
- } completionHandler:^{
- [[self delegate] createOptionMenuForPDFViewWithInvoice:invoice andSuperView:parentview];
- }];
- // update constraints…
- [UIView animateWithDuration:0.5 animations:^{
- [self.view layoutIfNeeded];
- }];
- if ([self respondsToSelector:@selector(edgesForExtendedLayout)]) {
- self.edgesForExtendedLayout = UIRectEdgeNone;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement