Rotating UIButton

后端 未结 4 1090
攒了一身酷
攒了一身酷 2021-01-20 11:33

I\'ve been trying to rotate a button using the following method:

-(IBAction)rotate:(id)sender{
    CGPoint pencilCenter = pencil.center;
    [pencil setCente         


        
4条回答
  •  轮回少年
    2021-01-20 12:20

    Import "QuartzCore/QuartzCore.h" and try this,

    CABasicAnimation *fullRotation;
    fullRotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
    fullRotation.delegate = self;
    fullRotation.fromValue = [NSNumber numberWithFloat:0];
    fullRotation.toValue = [NSNumber numberWithFloat:((360*M_PI)/180)];
    fullRotation.duration = 1.7;
    fullRotation.repeatCount = 2;
    [btnTemp.layer addAnimation:fullRotation forKey:@"360"];
    

提交回复
热议问题