{
NSMutableArray *_array;
}
- (void)viewDidLoad {
[super viewDidLoad];
_array= [[NSMutableArray alloc] initWithCapacity:0];
for(inti = 0; i < 9; i ++) {
UIImageView *galaxy = [[UIImageView alloc] initWithFrame:CGRectMake(self.view.frame.size.width/2-10, self.view.frame.size.height/2-10, 20, 20)];
galaxy.image= [UIImage imageNamed:@"26.png"];
[self.view addSubview:galaxy];
[_array addObject:galaxy];
}
NSLog(@"%@",_array);
[NSThread detachNewThreadSelector:@selector(move) toTarget:self withObject:nil];
}
- (void)move {
for(; ; ) {
[self performSelectorOnMainThread:@selector(freshUI) withObject:self waitUntilDone:YES];
[NSThread sleepForTimeInterval:0.5];
}
}
-(void)freshUI {
static float angle = 0;
for(int i = 0; i < 9; i ++) {
UIImageView *galaxy =_array[i];
angle += 3;
float x = 160 + 40 * (i+1) *cos((i + 1) * angle *M_PI/ 180);
float y = 240 - 40 * (i+1) *sin((i + 1) * angle *M_PI/ 180);
galaxy.center=CGPointMake(x, y);
}
}