ios7 - iOS autolayout animation doesn't work on iOS 7 but works on iOS 8 -
i trying animate full-screen view sliding in left , using whole space.
i have next code expected job fine on ios 8, fails on ios 7 :
[source.view addsubview:destination.view]; nsdictionary *viewsdict = @{@"tableview":destination.tableview, @"tapview": destination.tapview, @"destinationview": destination.view}; [source.view addconstraints:[nslayoutconstraint constraintswithvisualformat:@"v:|[destinationview]|" options:0 metrics:nil views:viewsdict]]; source.leftconstraint = [nslayoutconstraint constraintwithitem:destination.tableview attribute:nslayoutattributeleft relatedby:nslayoutrelationequal toitem:source.view attribute:nslayoutattributeleft multiplier:1.0 constant:-source.view.bounds.size.width]; [source.view addconstraint:source.leftconstraint]; source.rightconstraint = [nslayoutconstraint constraintwithitem:source.view attribute:nslayoutattributetrailing relatedby:nslayoutrelationequal toitem:destination.tapview attribute:nslayoutattributetrailing multiplier:1.0 constant:source.view.bounds.size.width]; [source.view addconstraint:source.rightconstraint]; [source.view layoutifneeded]; [uiview animatewithduration:.35f animations:^{ source.rightconstraint.constant = 0; source.leftconstraint.constant = 0; [source.view layoutifneeded]; }];
when gets executed on ios 7 destination.view
gets added screen straight away without animation. thought why might case ?
your animation block should contain [source.view layoutifneeded];
(see how animate constraint changes?).
you should alter constraints before block, :
[source.view layoutifneeded]; source.rightconstraint.constant = 0; source.leftconstraint.constant = 0; [uiview animatewithduration:.35f animations:^{ [source.view layoutifneeded]; }];
ios ios7 ios8 autolayout
No comments:
Post a Comment