UI组件缩放和旋转

旋转(注意:值是一个180°PI为单位)

#pragma mark 改变组件角度旋转

- (IBAction)rotationBlock:(UIButton *)sender {

    [UIView beginAnimations:nil context:nil];

    [UIView setAnimationDuration:.8];

    //旋转开始

    UIView *redBtn=[self.view viewWithTag:kRedBtnTag];

    CGAffineTransform transForm=redBtn.transform;

    redBtn.transform=CGAffineTransformRotate(transForm, sender.tag==7?-M_PI_4:M_PI_4);


    [UIView commitAnimations];

}

缩放

#pragma mark 改变组件大小

- (IBAction)changeSize:(UIButton *)sender {

     UIView *redBtn=[self.view viewWithTag:kRedBtnTag];

    [UIView beginAnimations:nil context:nil];

    [UIView setAnimationDuration:.8];

    //缩放开始

     CGAffineTransform  form=redBtn.transform;

    if (sender.tag==9) {

        redBtn.transform=CGAffineTransformScale(form, 1.5, 1.5);

    }else{

        redBtn.transform=CGAffineTransformScale(form, 0.8, 0.8);

    }

    [UIView commitAnimations];


}


你可能感兴趣的:(IOS,UI基础)