iOS-CATransform3D动画

声明属性
[@property](https://my.oschina.net/property) (nonatomic,strong) UIView *cicleView;
构建界面
- (void)transform3dAnimation{
    CGFloat width = self.view.bounds.size.width-100;
    _cicleView = [[UIView alloc]initWithFrame:CGRectMake(50, 80, width, width)];
    [self.view addSubview:_cicleView];
    _cicleView.clipsToBounds = YES;
    _cicleView.layer.cornerRadius = width/2;
    UIColor *color = [UIColor colorWithRed:arc4random()%256/255.0 green:arc4random()%256/255.0 blue:arc4random()%256/255.0 alpha:1.0];
    _cicleView.backgroundColor = [color colorWithAlphaComponent:1.0 ];
    UILabel *lab = [[UILabel alloc]init];
    lab.frame = CGRectMake((width-width/2)/2, (width-30)/2, width/2, 30);
    lab.font = [UIFont systemFontOfSize:30];
    lab.textAlignment = NSTextAlignmentCenter;
    lab.text = @"30000步";
    [_cicleView addSubview:lab];
    
    UISlider *slider = [[UISlider alloc]initWithFrame:CGRectMake(40, CGRectGetMaxY(_cicleView.frame)+30, 300, 30)];
    [self.view addSubview:slider];
    [slider addTarget:self action:@selector(changeValue:) forControlEvents:UIControlEventValueChanged];
}
添加动画
- (void)changeValue:(UISlider *)slider{
    
    CATransform3D t3d = CATransform3DIdentity;
    t3d = CATransform3DRotate(t3d, slider.value*M_PI_2, 1, 0, 0);
    t3d = CATransform3DScale(t3d, slider.value*0.15+1, 1, 1);
    _cicleView.layer.transform = t3d;
    _cicleView.alpha = 1-slider.value;
    
}

Paste_Image.png

转载于:https://my.oschina.net/hehuiqi/blog/1591204

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值