iPhone iOS how to flip/reflect any UIView in - place?

后端 未结 2 1999
甜味超标
甜味超标 2021-02-15 17:16

I know how to flip/reflect/rotate a UIImage by re-drawing it within it\'s bounds.

- (IBAction)reflectImageView:(UIImageView)imageView {

    UIGraphicsBeginImag         


        
2条回答
  •  时光说笑
    2021-02-15 17:56

     [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:0.75];
        [UIView setAnimationDelegate:self];
        [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.activeView cache:YES];
        //        [self.activeView removeFromSuperview];
        [UIView commitAnimations];
    
        NSNumber* isReflected = [self.activeView.attributedView.attributes valueForKey:kIsReflected];
        if(isReflected.boolValue)
        {
            self.activeView.transform = CGAffineTransformMakeScale(1,1);
            [self.activeView.attributedView.attributes setValue: [NSNumber numberWithBool:NO]  forKey:kIsReflected];
        }else {
            //do reflection
            self.activeView.transform = CGAffineTransformMakeScale(-1,1);
            [self.activeView.attributedView.attributes setValue: [NSNumber numberWithBool:YES]  forKey:kIsReflected];
        }
    

    Above code is used for UIView Animation. Where you will get an options for various type animation.

提交回复
热议问题