ios7 - Animation with Autolayout -


i don't use ib. laying out code.

i have uitoolbar on top of view. setting height 64 or , width stretch horizontally fit screen width. when first launch app, perfect. change orientation, toolbar resizes, good.

now comes animation part.

when swipe on view, toolbar should move on top of screen , hide. when swipe down on view, toolbar should come down.

i tried setting constraints in following manner.

initially this.

// width [self.view addconstraints:[nslayoutconstraint constraintswithvisualformat:@"h:|-[toolbar]-|" options:0 metrics:nil views:viewdict]]; // height [self.view addconstraints:[nslayoutconstraint constraintswithvisualformat:@"v:[toolbar(toolbarheight)]" options:0 metrics:metricdict views:viewdict]]; 

now, during swipe up

[self.view removeconstraint:[nslayoutconstraint constraintwithitem:self.toolbar attribute:nslayoutattributetop relatedby:nslayoutrelationequal toitem:self.view attribute:nslayoutattributetop multiplier:1 constant:0]]; [self.view addconstraint:[nslayoutconstraint constraintwithitem:self.toolbar attribute:nslayoutattributebottom relatedby:nslayoutrelationequal toitem:self.view attribute:nslayoutattributetop multiplier:1 constant:0]]; 

but breaking constraint supposed bring down , staying up.

needless say, driving me mad. solutions?

edit:

on closer analysis, "removeconstraint" wasn't working expected. basically, wasn't removing constraint wanted remove. self.view.constraints nsarray. need find simple way remove exact constraint want.

so need create heigh constraint using long form creating single constraint. , assign property. have change constant value. swipe set height constraint constant zero. swipe down change height constraint constant desired height.

you don't need add , remove constraint every time.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -