How can I flip a UIImageView?

后端 未结 6 1034
小蘑菇
小蘑菇 2021-02-09 01:58

How can I flip an UIImageView?

6条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-09 02:47

    Using @Fellowsoft code I have create a method rotation Animation.

    thanks to Fellowsoft!!

    -(void)rotateImage:(UIImageView*)image withDuration:(float)duration isHorizzonal:(BOOL)horizontal{
        [UIView animateWithDuration:duration/2.0 animations:^{image.transform = horizontal?
                                                                    CGAffineTransformMake(image.transform.a * -1, 0, 0, 1, image.transform.tx, 0)
                                                                    :CGAffineTransformMake(1, 0, 0, image.transform.d * -1, 0, image.transform.ty);}
                         completion:^(BOOL finished)
                                        {
                                        //half animation
                                        [UIView animateWithDuration:duration/2.0 animations:^{image.transform = horizontal?
                                                                            CGAffineTransformMake(image.transform.a * -1, 0, 0, 1, image.transform.tx, 0)
                                                                            :CGAffineTransformMake(1, 0, 0, image.transform.d * -1, 0, image.transform.ty);}
                                                                            completion:^(BOOL finished)    { }];
                         }];
    }
    

提交回复
热议问题