2011-07-24 50 views
0

我有以下代碼,我在UIImageView上硬編碼UImage。然而,我被要求修改,以便應用程序允許用戶選擇UIImageView上的哪個位置,UIImage需要放置在哪裏。我想用戶點擊屏幕,應用程序存儲我放置UIImage的x,y座標。我只是不知道該怎麼做。如何修改我的代碼以允許用戶在UIImageView上定位UIImage?

CGPDFDocumentRef document = CGPDFDocumentCreateWithURL((CFURLRef)pdfUrl); 

      //lets now convert the fax to an image 
      CGPDFPageRef page = CGPDFDocumentGetPage(document, 1); 
      UIImage *pageImage = [PDFPageConverter convertPDFPageToImage:page withResolution:144]; 

     UIImage *shieldLogo = [UIImage imageNamed:@"shield_bw.gif"]; 
     UIGraphicsBeginImageContext(pageImage.size); 
     [pageImage drawInRect:CGRectMake(0, 0, pageImage.size.width, pageImage.size.height)]; 
     [shieldLogo drawInRect:CGRectMake(150, 100, shieldLogo.size.width, shieldLogo.size.height)]; 
     [theSignature drawAtPoint:CGPointMake(200, 100) withFont:[UIFont fontWithName:@"Arial" size:15.0]]; 
     [theSignature2 drawAtPoint:CGPointMake(200, 120) withFont:[UIFont fontWithName:@"Arial" size:15.0]]; 
     UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext(); 
     UIGraphicsEndImageContext(); 
     [image setImage:resultingImage]; 

回答

1

讓你的子類迴應觸摸使用-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;事件,在其中您會相應地修改圖像視圖的frame財產。

相關問題