码迷,mamicode.com
首页 > 编程语言 > 详细

两个算法,

时间:2015-01-12 17:11:04      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:

-(void)lifeViewAnimation

{

    static int a = 0;

    static BOOL isAdd = NO;

    if (a >= 310) {

        a = a - 3;

        isAdd = NO;

    }else if(a == 0){

        a = a + 3;

        isAdd = YES;

    }else if (isAdd)

    {

        a = a + 3;

    }else if (!isAdd)

    {

        a = a - 3;

    }

    self.lifeView.frame = CGRectMake(a, self.lifeView.frame.origin.y, self.lifeView.frame.size.width, self.lifeView.frame.size.height);

}

 

 

-(void)lifeViewAnimation

{

    static int a = 0;

    static int beforeA = 0;

    static BOOL isPlus = YES;

    

    if(a <= 0) {

        isPlus = YES;

    }

    if(a >= self.view.frame.size.width){

        isPlus = NO;

    }

    beforeA = a;

    

    if (isPlus) {

        a = a + 3;

    }else{

        a = a - 3;

    }

    if (a == beforeA+3) {

        isPlus = YES;

    }else{

        isPlus = NO;

    }

     self.lifeView.frame = CGRectMake(a, self.lifeView.frame.origin.y, self.lifeView.frame.size.width, self.lifeView.frame.size.height);

}

两个算法,

标签:

原文地址:http://www.cnblogs.com/guligei/p/4218644.html

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