2010-04-07 59 views
1

嗨,我是用下面这段代码,让用户在我的应用程序在一个UIView组件“画”的招牌:绘制的图像完全是出于

UIGraphicsBeginImageContext(signature.frame.size); 
    [drawImage.image drawInRect:CGRectMake(0, 0, signature.frame.size.width, signature.frame.size.height)]; 
    CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); 
    CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5.0); 
    CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1.0, 0.0, 0.0, 1.0); 
    CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); 
    CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); 
    CGContextStrokePath(UIGraphicsGetCurrentContext()); 
    CGContextFlush(UIGraphicsGetCurrentContext()); 
    drawImage.image = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext() 

我遇到的问题是,绘图不仅在绘图时与模拟器中的指针不一致,图像超出了指定的UIView组件范围,而且越来越小,聚焦越多,就像您在此图像中看到的那样: alt text http://dl.dropbox.com/u/1545603/iphone-signature-issues.png

并在几行后显示确切的边界是我可以画的地方: alt text http://dl.dropbox.com/u/1545603/iphone-signature-issues2.png

关于这里发生了什么的任何想法?

lastPoint.y被定义为:lastPoint.y -= 20;

在地球上这里发生了什么任何想法?

回答

0

好了,想通了:

我可能会在以后张贴代码,但是,UIView的借鉴设置为:

signature.frame而应该signature.bounds所有属性。

最后,删除所有lastPoint.ycurrentPoint.y的定义。现在

,在这一点上,我会考虑使用变量来代替UIGraphicsGetCurrentContext()

0

也许,不是使用屏幕上的位置并绘制到白色视图,而是使其相反,从而导致线条出现在白色视图之外。

只是一个想法。对不起,但从我的iPhone这是我可以给的最好的答案。

顺便说一句,我真的建议在设备上进行调试。我发现了大量的可用性缺陷,它对于衡量性能要好得多。

我迫不及待想看这个应用程序,给我发电子邮件的细节,我会在星期五看看。如果你愿意,我有一个计算项目应用程序和一个网站,为你进行beta/alpha测试!

+0

TY丹:)我的iPhone上试过了,这是相同的:( – bear 2010-04-07 20:09:19