求一个透视图片的例子。
例如可以拖动一个透明的矩形框,然后透视的内容可以 呈现在这个透明的矩形框中,并且,可以拖动这个矩形框移动。里面相应的内容也跟着更换移动。--------------------编程问答-------------------- 呵呵 这个看来不难⋯⋯ --------------------编程问答-------------------- 在Touch事件中加:
UIGraphicsBeginImageContext(透明框View);
CGContextDrawImage(UIGraphicsGetCurrentContext(), CGRect 透明框rect,CGImageRef 背景image);
UIGraphicsEndImageContext(); --------------------编程问答-------------------- 涉及到三层,注意Touch事件的选取和透射 --------------------编程问答-------------------- 非常感谢楼上。
刚弄iphone,期望个例子或者是参考文章。
--------------------编程问答-------------------- 以前见过一个demo
两张图片叠加,上面加一个橡皮擦,擦掉触摸部分区域,漏出底层图片。
跟这个大同小异⋯⋯
换一个函数就可以了
到cocoachina上自己找找 --------------------编程问答-------------------- 函数参考 CoreGraphics - CGContext.h
--------------------编程问答-------------------- 那个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();
}
} --------------------编程问答-------------------- 对不起,我还是不会。
橡皮擦的那个例子在这里http://www.cocoachina.com/bbs/read.php?tid-43631.html --------------------编程问答-------------------- 不才,刚刚做了一个例子。站内信留邮箱,给你发过去⋯⋯ --------------------编程问答-------------------- 万分感谢。 --------------------编程问答--------------------
等不到你给我邮箱了
有需要的童鞋,可以到这里下载
http://download.csdn.net/detail/ybh37/3796404
也可以留下邮箱,有时间的时候给大家发过去。Xcode4+ios5 --------------------编程问答-------------------- 不就是用touchesBegan, touchesMoved事件里跟着移动里面的视图不就ok了
补充:移动开发 , iPhone