求一个透视图片的例子。

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


...全文
273 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
程序员小迷 2012-01-12
  • 打赏
  • 举报
回复
不就是用touchesBegan, touchesMoved事件里跟着移动里面的视图不就ok了
咸清 2011-11-15
  • 打赏
  • 举报
回复

等不到你给我邮箱了
有需要的童鞋,可以到这里下载
http://download.csdn.net/detail/ybh37/3796404
也可以留下邮箱,有时间的时候给大家发过去。Xcode4+ios5
咸清 2011-11-14
  • 打赏
  • 举报
回复
不才,刚刚做了一个例子。站内信留邮箱,给你发过去⋯⋯
guguqiaqia 2011-11-14
  • 打赏
  • 举报
回复
万分感谢。
guguqiaqia 2011-11-11
  • 打赏
  • 举报
回复
对不起,我还是不会。

橡皮擦的那个例子在这里http://www.cocoachina.com/bbs/read.php?tid-43631.html
guguqiaqia 2011-11-11
  • 打赏
  • 举报
回复
那个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();
}
}
咸清 2011-11-09
  • 打赏
  • 举报
回复
涉及到三层,注意Touch事件的选取和透射
咸清 2011-11-09
  • 打赏
  • 举报
回复
在Touch事件中加:
UIGraphicsBeginImageContext(透明框View);
CGContextDrawImage(UIGraphicsGetCurrentContext(), CGRect 透明框rect,CGImageRef 背景image);
UIGraphicsEndImageContext();
咸清 2011-11-09
  • 打赏
  • 举报
回复
呵呵 这个看来不难⋯⋯
咸清 2011-11-09
  • 打赏
  • 举报
回复
函数参考 CoreGraphics - CGContext.h
咸清 2011-11-09
  • 打赏
  • 举报
回复
以前见过一个demo
两张图片叠加,上面加一个橡皮擦,擦掉触摸部分区域,漏出底层图片。
跟这个大同小异⋯⋯
换一个函数就可以了
到cocoachina上自己找找
guguqiaqia 2011-11-09
  • 打赏
  • 举报
回复
非常感谢楼上。
刚弄iphone,期望个例子或者是参考文章。

29,029

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧