例如可以拖动一个透明的矩形框,然后透视的内容可以 呈现在这个透明的矩形框中,并且,可以拖动这个矩形框移动。里面相应的内容也跟着更换移动。
 

解决方案 »

  1.   

    在Touch事件中加:
    UIGraphicsBeginImageContext(透明框View);
    CGContextDrawImage(UIGraphicsGetCurrentContext(), CGRect 透明框rect,CGImageRef 背景image);
     UIGraphicsEndImageContext();
      

  2.   

    涉及到三层,注意Touch事件的选取和透射
      

  3.   

    非常感谢楼上。
    刚弄iphone,期望个例子或者是参考文章。
      

  4.   

    以前见过一个demo
    两张图片叠加,上面加一个橡皮擦,擦掉触摸部分区域,漏出底层图片。
    跟这个大同小异⋯⋯
    换一个函数就可以了
    到cocoachina上自己找找
      

  5.   

    函数参考 CoreGraphics - CGContext.h
      

  6.   

    那个demo已经找到,就是不只怎么改动。关键代码如下:-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
    {
    UITouch *touch = [touches anyObject];
    if(canEarse)
    { CGPoint currentPoint = [touch locationInView:imageView];

            UIGraphicsBeginImageContext(self.imageView.frame.size);
            
    [imageView.image drawInRect:imageView.bounds];
            //
           
            CGContextClearRect (UIGraphicsGetCurrentContext(), CGRectMake(0, currentPoint.y-15, 1024, 30));
            
            //CGContextDrawImage(UIGraphicsGetCurrentContext(), CGRectMake(0, currentPoint.y, 1024, 30),charaImage);  
            
            
            //CGContextFillRect(UIGraphicsGetCurrentContext(), CGRectMake(0, currentPoint.y-30, 1024, 30)); 

            imageView.image = UIGraphicsGetImageFromCurrentImageContext(); 
            
            UIGraphicsEndImageContext();
    }
    }
      

  7.   

    对不起,我还是不会。橡皮擦的那个例子在这里http://www.cocoachina.com/bbs/read.php?tid-43631.html
      

  8.   


    等不到你给我邮箱了
    有需要的童鞋,可以到这里下载
    http://download.csdn.net/detail/ybh37/3796404
    也可以留下邮箱,有时间的时候给大家发过去。Xcode4+ios5
      

  9.   

    不就是用touchesBegan, touchesMoved事件里跟着移动里面的视图不就ok了