Reflection and Mirror UIImage
I have a UIImage, I need to flip and mirror. I did it using UIImageView. I have two problems with this.
-
This does not change the image in view only. So when I use the image it is not inverted or I get an error.
-
If I use the same transform twice, it does nothing the second time.
Example code: (I am new to IOS programming and regret any bad code.)
Flip call:
// ImageHolder is a UIImageView
ImageHolder = [self flip:ImageHolder FlipType:@"V"];
What does it cause:
- (UIImageView *)flip:(UIImageView *) fvImageView FlipType:(NSString *)FlipType {
UIImageView *newView = [[UIImageView alloc] init];
newView = fvImageView;
if ( FlipType == @"V"){
newView.transform = CGAffineTransformMakeScale(-1, 1);
} else if ( FlipType == @"H"){
newView.transform = CGAffineTransformMakeScale(1, -1);
}else if ( FlipType == @"VH"){
newView.transform = CGAffineTransformMakeScale(-1, -1);
}else if ( FlipType == @"N"){
newView.transform = CGAffineTransformMakeScale(1, 1);
}
return newView;
[newView release]; newView= nil;
}
Thanks for any help you can give!
+3
source to share
1 answer
Image does not flip because you release the image
[newView release];
then do nil
newView= nil;
and then returns
return newView;
As a result, you return nil after performing some operations. I think this is enough to make changes to the "fvImageView" object that you pass as an argument to the function.
0
source to share