iphone - Float a UIView around the screen in the background -


this question has answer here:

so i'm trying long running animation uiviews. i'm trying accomplish take square subview , have float randomly around screen in background (like leaf floating on pond). hoping regular animations far i've had problems animation stops setting option begin @ current position. know of simple way this?

i saw moving object randomly around screen isn't going cause stack overflow due recursion?

also, i'm asking how without added library/framework.

thanks!

i wrote code you:

- (cgfloat) distancebetweentwopoints: (cgpoint) point1 : (cgpoint) point2 {     cgfloat dx = point2.x - point1.x;     cgfloat dy = point2.y - point1.y;     return sqrt(dx*dx + dy*dy ); }  #define kmovingspeed 25 //pixel per second - (void) floatview : (id) view_{     uiview *view = (uiview *)view_;     cgpoint viewcenter = view.center;     cgpoint nextcenter = cgpointmake(arc4random() % 320, arc4random() % (([self.view bounds].size.height > 480)?568:460));//or chech orientation     if (cgpointequaltopoint(viewcenter, nextcenter))         [self floatview:view];      float distance = [self distancebetweentwopoints:viewcenter :nextcenter];     double time = distance / kmovingspeed;      [uiview animatewithduration:time                      animations:^{                          [view setcenter:nextcenter];                      }                      completion:^(bool finished) {                          [self floatview:view];                      }]; } 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -