码迷,mamicode.com
首页 > 移动开发 > 详细

ios中使view向左移动,且右边不动

时间:2014-08-25 15:02:44      阅读:248      评论:0      收藏:0      [点我收藏+]

标签:ios   uiview   移动   

ios中使view向左移动,且右边不动

by 伍雪颖


-(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)];
                     }];


ios中使view向左移动,且右边不动

标签:ios   uiview   移动   

原文地址:http://blog.csdn.net/rainlesvio/article/details/38819987

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!