iphone - How do I shift two UIViews 270px to the right in AutoLayout in code? -


i have uiview offscreen 400 pixels left , 280 pixels wide.

i'm trying shift main uiview right 280 pixels , have offscreen uiview move onscreen right simultaneously sidebar.

i've been stuck here.

is there way in code , use nslayoutconstraints?

edit:

-(void) setupsidebar{   self.sidebarviewcontroller = [self.storyboard instantiateviewcontrollerwithidentifier:@"sidebarvc"];   self.sidebarviewcontroller.view.frame = cgrectmake(-400, 0, 280, self.sidebarviewcontroller.view.bounds.size.height);   [self.navigationcontroller addchildviewcontroller:self.sidebarviewcontroller];   [self.navigationcontroller.view addsubview:self.sidebarviewcontroller.view];   [self.view insertsubview:self.sidebarviewcontroller.view abovesubview:self.view]; }  -(void)slidetotheright{   [uiview animatewithduration:0.5 animations:^{     self.sidebaropened = yes;     //self.sidebarviewcontroller.view.frame = cgrectmake(-280, 0, 280, self.sidebarviewcontroller.view.bounds.size.height);     self.view.frame = cgrectmake(280, 0, self.view.bounds.size.width, self.view.bounds.size.height);      }];    [uiview animatewithduration:0.1 animations:^{     self.sidebarviewcontroller.view.transform = cgaffinetransformmaketranslation(120, 0);   }]; }  -(void) slideback{   [uiview animatewithduration:0.3 animations:^{     self.sidebaropened = no;     //self.sidebarviewcontroller.view.frame = cgrectmake(-280, 0, 280, self.sidebarviewcontroller.view.bounds.size.height);     self.view.frame = cgrectmake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height);   }];    [uiview animatewithduration:0.2 animations:^{     self.sidebarviewcontroller.view.transform = cgaffinetransformmaketranslation(-120, 0);   }]; } 

sure, can this. make iboutlet constraint want change, , modify constant parameter in code. so, if had outlet constraint left edge of superview called leftcon, this:

self.leftcon.constant += 200; 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -