ios - Constraint animation issue -
i'm building app whereas i'm facing strange issue constraints.
i'm trying animate height constraint attached uiview
in storyboard, simulator displays weird behaviour. debug, created new, ios 9.2 project , added uibutton
, set horizontal pin , superview top constraint it, linked top constraint header file , button ibaction
.
when calling code alone:
- (ibaction)myaction:(id)sender { self.topconstraint.constant += 150.0f; }
the button snaps 150 points down, without calling [self.view layoutifneeded];
.
however, when i'm using code:
- (ibaction)myaction:(id)sender { self.topconstraint.constant += 150.0f; [self.view setneedsupdateconstraints]; [uiview animatewithduration:1 animations:^{ [self.view layoutifneeded]; }]; }
the button slides down.
how come snaps there without me calling layoutifneeded
when there's no animation block? find strange.
here's header file:
#import <uikit/uikit.h> @interface viewcontroller : uiviewcontroller @property (weak, nonatomic) iboutlet nslayoutconstraint *topconstraint; @end
and top nslayoutconstraint
setup:
calling layoutifneeded on view merely forces update of view early, rather waiting update through drawing cycle, when animate constraint placing layoutifneeded inside animation block animating change, in 2nd instance not call layoutifneeded, drawing cycle comes around , updates view without animation.
Comments
Post a Comment