简体   繁体   English

我想让imageView Position垂直倒置

[英]I want to get imageView Position vertically upside down

In the Below image there are two imageViews one is body imageView and another one is black tattoo imageview , Now i am getting the tatoo imageView position with the below code 在下面的图像中,有两个imageViews一个是身体imageView,另一个是黑色纹身imageview,现在我用下面的代码获取纹身imageView的位置

appDelegate.xFloat= self.imgView.frame.origin.x;
appDelegate.yFloat= self.imgView.frame.origin.y;
appDelegate.widthFloat= self.imgView.frame.size.width;
appDelegate.heightFloat= self.imgView.frame.size.height;

在此处输入图片说明

Now i need to put the tattoo image in another view controller as we are seeing in the image(Here Car is in reverse position), But with the help of ( appDelegate.xFloat , appDelegate.yFloat , appDelegate.widthFloat , appDelegate.heightFloat ) these I am setting the tattooimageview frame. 现在我需要将纹身图像放到我们在图像中看到的另一个视图控制器中(这里汽车处于反向位置),但是要借助( appDelegate.xFloatappDelegate.yFloatappDelegate.widthFloatappDelegate.heightFloat )这些我正在设置tattooimageview框架。 But i am getting the image as shown below in another view 但是我在另一个视图中得到如下图所示的图像

在此处输入图片说明

I need to place the car image in reverse as we seen in first image. 正如我们在第一个图像中看到的那样,我需要将汽车图像反向放置。 Please Guide Me 请指导我

My requirement is not only rotation.. The image may be in any position like below 我的要求不仅是旋转。图像可能在以下任何位置

在此处输入图片说明

you must contructor appDelegate before use it. 您必须先构造appDelegate才能使用它。 by: 通过:

appDelegate = (AppDelegate *) [[UIApplication sharedApplication] delegate];

It is strange that one image is not rotating and the other one is rotating. 奇怪的是,一个图像没有旋转而另一图像正在旋转。 I am assuming that one of the images is a background image or what ever, but you can use transform properties to change the rotation. 我假设其中一幅图像是背景图像或其他图像,但是您可以使用transform属性更改旋转角度。 Some thing similar to the code below should show you the same image in two orientations. 类似于下面的代码,应该在两个方向上显示相同的图像。

UIImage *image = [UIImage imageNamed:@"image.png"];

UIImageView *iv1 =[[UIImageView alloc] initWithImage:image];

[self.view addSubview:iv1];

UIImageView *iv2 = [[UIImageView alloc] initWithImage:image];

[iv2 setFrame:CGRectMake(100,100,image.size.width,image.size.height)];

[iv2 setTransform:CGAffineTransformMakeRotation(-M_PI)];

[self.view addSubview:iv2];

Babul, Looks like you are trying to create an image. Babul,看起来您正在尝试创建图像。 For that you need to use some thing called ImageContext. 为此,您需要使用称为ImageContext的东西。 I have given some code, where you draw an image in a context and then get the image out. 我给出了一些代码,您可以在上下文中绘制图像,然后将其取出。

UIGraphicsBeginImageContext(CGSizeMake(300,300));

UIImage *image = [UIImage imageNamed:@"breakpoint place.png"];

[image drawAtPoint:CGPointMake(0,0)];

UIImage *image2 = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

UIImageView *iv = [[UIImageView alloc] initWithImage:image2];

[iv setFrame:CGRectMake(100,100,image2.size.width,image2.size.height)];

[self.view addSubview:iv];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM