8
votes

Comment puis-je retourner un uiimageview?

Comment puis-je retourner un uiImageView?


1 commentaires

Parlez-vous de - (bool) isflipped; {retour oui; } si par chance?


6 Réponses :


7
votes

Vous devriez être capable de retourner la vue verticalement avec: xxx


0 commentaires

17
votes

Créer deux UIImageView FrontimageView & BackimageView

Créer un uImageView contenant uIImageView p>

Afficher FrontImageView au début. P>

Après avoir retourné, show backimageView P>

Code: P>

// before flip
frontImageView = [[UIImageView alloc] initWithImage:[UIImage 
                    imageNamed:@"test.png"]];

containerView = [[UIView alloc] initWithFrame:frontImageView.bounds];
containerView.center = CGPointMake(200,200);

[self.view addSubview:containerView];
[containerView addSubview:frontImageView];

-(IBAction)flipButtonClicked:(id)sender
{
     backImageView = [[UIImageView alloc] initWithImage:[UIImage 
                            imageNamed:@"cardback.png"]];
     backImageView.center = frontImageView.center;
     [UIView beginAnimations:nil context:NULL];
     [UIView setAnimationDuration:1.0];
     [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft 
                            forView:containerView 
                              cache:YES];
     [frontImageView removeFromSuperview];
     [containerView addSubview:backImageView];
     [UIView commitAnimations];
}


0 commentaires

4
votes
#import <QuartzCore/QuartzCore.h>
...
- (UIImage *) flipImageVertically:(UIImage *)originalImage direction:(NSString *)axis {
UIImageView *tempImageView = [[UIImageView alloc] initWithImage:originalImage];

UIGraphicsBeginImageContext(tempImageView.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGAffineTransform flipVertical = CGAffineTransformMake(0, 0, 0, 0, 0, 0);
if([axis isEqualToString:@"x"])
{
    flipVertical = CGAffineTransformMake(
                                         1, 0, 0, -1, 0, tempImageView.frame.size.height
                                        );
}
else if([axis isEqualToString:@"y"] )
{
    flipVertical = CGAffineTransformMake(
                                         -1, 0, 0, 1, tempImageView.frame.size.width, 0
                                        );
}
CGContextConcatCTM(context, flipVertical);  

[tempImageView.layer renderInContext:context];

UIImage *flipedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[tempImageView release];

return flipedImage;
}  

0 commentaires

6
votes

J'ai modifié le code des blasters sonores un peu pour renvoyer un UIImageView. Cependant, ce code ne vous permet pas de retourner l'image verticalement et horizontalement en même temps. Une solution pour cela devrait être plutôt facile cependant.

- (UIImageView *) flipImage:(UIImageView *)originalImage Horizontal:(BOOL)flipHorizontal {
if (flipHorizontal) {

    originalImage.transform = CGAffineTransformMake(originalImage.transform.a * -1, 0, 0, 1, originalImage.transform.tx, 0);
}else {

    originalImage.transform = CGAffineTransformMake(1, 0, 0, originalImage.transform.d * -1, 0, originalImage.transform.ty);
}    
return originalImage; }  


1 commentaires

J'ai modifié pour renvoyer la mine horizontale et verticale temp.backgroundImage.transform = cgaffinetransformMake (temp.backgroundImage.transform.a * -1, 0, 0, -1, temp.backgroundImage.transform.tx, 0);



3
votes

Utilisation de @fellowsoft code J'ai créé une animation de la méthode de rotation.

Merci à Fellowsoft strong> !! p>

-(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)    { }];
                     }];
}


0 commentaires

2
votes

pour flip horizontalement xxx

pour basculer verticalement xxx


0 commentaires