2012-12-10 27 views
1

在下面的圖片有兩種imageViews一個是身體ImageView的,另一種是黑色的紋身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; 

enter image description here

現在我需要把文身圖像中的另一個視圖控制器,因爲我們在圖像中看到(這裏的車在倒車位置),但隨着的幫助(appDelegate.xFloatappDelegate.yFloatappDelegate.widthFloatappDelegate.heightFloat)THES e我正在設置tattooimageview框架。 但我得到的圖像作爲另一種觀點

enter image description here

我需要把汽車圖像反轉,因爲我們在第一個圖像看到如下圖所示。 請指導我

我的要求是不僅轉動。該圖片可以是任何位置,像下面

enter image description here

+0

您是否嘗試過使用UIView.transform將圖像翻轉過來? – user1781290

+0

我沒有使用,因爲UIView.transform可能會旋轉圖像..但我們不知道用戶如何旋轉圖像..所以,我需要得到該圖像,我想把它放在另一個視圖控制器@ user1781290 – Babul

回答

0

奇怪的是,一個像不旋轉,另一個是旋轉的。我假設其中一個圖像是背景圖像或以前的圖像,但您可以使用變換屬性更改旋轉。有些與下面的代碼類似的東西應該會在兩個方向上顯示相同的圖像。

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]; 
+0

喜斯里,你可以看看編輯過的問題一次。我想要每次都改變的圖像@ Srikanth – Babul

+0

那麼你如何接受用戶輸入。您可以閱讀有關旋轉手勢並向UIImageView添加旋轉手勢。這樣,你可以讓用戶旋轉它,一旦他完成旋轉,圖像可以在那個位置。也許你可以提供更多關於你想要做什麼的細節。 – Srikanth

+0

我沒有采取任何輸入,通過手勢旋轉...旋轉完成後,我想將該圖像精確保存到UIImage @Srikanth – Babul

0

必須構造器的appDelegate之前使用它。 由:

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

我做了這在我的「ViewDidLoad」我得到紋身imageview的位置也...但我想紋身imageview圖像像汽車是在相反...但我得到的實際車圖像........我以另一種方式嘗試,也就是當我們導航到另一個視圖時保存圖像。但我沒有得到解決方案@朱洲 – Babul

0

Babul,看起來像你正在嘗試創建一個圖像。爲此你需要使用一些名爲ImageContext的東西。我已經給出了一些代碼,在上下文中繪製圖像,然後獲取圖像。

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];