ios中使view向左移动,且右边不动
ios中使view向左移动,且右边不动
-(void)signUpAndLoginAnimation:(BOOL)showSignUp { CGFloat LogInWidthChange = (showSignUp)?-120:120; [UIView animateWithDuration:0.3f animations:^{ CGRect newFrame = self.logInView2.frame; newFrame.origin.x -= LogInWidthChange; newFrame.size.width += LogInWidthChange; CGFloat newSizeX = self.logInView2.frame.size.width + LogInWidthChange; CGFloat ofsetX = LogInWidthChange; [self.logInView2 setFrame:CGRectMake(self.logInView2.frame.origin.x-ofsetX, self.logInView2.frame.origin.y, newSizeX, self.logInView2.frame.size.height)]; }]; }
发现写复杂了:
[UIView animateWithDuration:0.3f animations:^{ CGFloat changeWidth = (showSignUp)?-120:120; [self.logInView2 setFrame:CGRectMake(self.logInView2.left-changeWidth, self.logInView2.top, self.logInView2.width + changeWidth, self.logInView2.height)]; }];
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。