UIView动画 防多星球环绕转动

#import "RootViewController.h"

@interface RootViewController () {
    UIView *oneView;
    UIView *middleView;
    UIView *bigView;
}

@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor blackColor];
    
    bigView = [[UIView alloc] initWithFrame:CGRectMake(20, 160, 335, 335)];
//    bigView.backgroundColor = [UIColor orangeColor];
    bigView.layer.borderWidth = 1;
    bigView.layer.borderColor = [UIColor colorWithWhite:1.000 alpha:0.200].CGColor;
    bigView.layer.cornerRadius = 167.5;
    [self.view addSubview:bigView];
    [bigView release];
    [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(taiji2) userInfo:nil repeats:YES];
    
    
    UIView *bigView1 = [[UIView alloc] initWithFrame:CGRectMake(317.5, 150, 35, 35)];
    bigView1.backgroundColor = [UIColor colorWithRed:0.844 green:0.872 blue:0.610 alpha:1.000];
    bigView1.layer.cornerRadius = 17.5;
    [bigView addSubview:bigView1];
    [bigView1 release];

    
    middleView = [[UIView alloc] initWithFrame:CGRectMake(42.5, 42.5, 250, 250)];
//    middleView.backgroundColor = [UIColor yellowColor];
    middleView.layer.borderWidth = 1;
    middleView.layer.borderColor = [UIColor colorWithWhite:1.000 alpha:0.200].CGColor;
    middleView.layer.cornerRadius = 125.5;
    [bigView addSubview:middleView];
    [middleView release];
    [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(taiji1) userInfo:nil repeats:YES];
    
    
    UIView *middleView1 = [[UIView alloc] initWithFrame:CGRectMake(232.5, 107.5, 35, 35)];
    middleView1.backgroundColor = [UIColor colorWithRed:0.689 green:0.624 blue:0.632 alpha:1.000];
    middleView1.layer.cornerRadius = 17.5;
    [middleView addSubview:middleView1];
    [middleView1 release];
    
    
    oneView = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 150, 150)];
//    oneView.backgroundColor = [UIColor cyanColor];
    oneView.layer.borderWidth = 1;
    oneView.layer.borderColor = [UIColor colorWithWhite:1.000 alpha:0.200].CGColor;
    oneView.layer.cornerRadius = 75;
    [middleView addSubview:oneView];
    [oneView release];
    [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(taiji) userInfo:nil repeats:YES];
    
    
    
    UIView *smillView = [[UIView alloc] initWithFrame:CGRectMake(130, 55, 40, 40)];
    smillView.backgroundColor = [UIColor colorWithRed:0.758 green:0.714 blue:0.535 alpha:1.000];
    smillView.layer.cornerRadius = 20;
    [oneView addSubview:smillView];
    [smillView release];
    
    UIView *centreView = [[UIView alloc] initWithFrame:CGRectMake(45, 45, 60, 60)];
    centreView.backgroundColor = [UIColor colorWithRed:0.600 green:0.400 blue:0.200 alpha:0.220];
    centreView.layer.cornerRadius = 30;
    [oneView addSubview:centreView];
    [centreView release];
    
    
}




//oneView转
- (void)taiji {
    [UIView animateWithDuration:3 delay:0 options:(UIViewAnimationOptionCurveLinear) animations:^{
        oneView.transform = CGAffineTransformRotate(oneView.transform, M_PI_4);
    } completion:^(BOOL finished) {
    }];
}


//middleView转
- (void)taiji1 {
    [UIView animateWithDuration:3 delay:0 options:(UIViewAnimationOptionCurveLinear) animations:^{
        middleView.transform = CGAffineTransformRotate(oneView.transform, M_PI_4);
    } completion:^(BOOL finished) {
    }];
}

//middleView转
- (void)taiji2 {
    [UIView animateWithDuration:3 delay:0 options:(UIViewAnimationOptionCurveLinear) animations:^{
        bigView.transform = CGAffineTransformRotate(oneView.transform, M_PI_4);
    } completion:^(BOOL finished) {
    }];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值