【发布时间】:2014-10-06 15:22:01
【问题描述】:
我有一个非常奇怪的问题。在 iOS8 中,仅在 ipad 2 上(适用于所有设备上的 iOS7 和 iOS8 中的 mini),我拥有的签名面板将导致线条/绘制的对象随着用户将手指放在 UIImageView 上的时间越长而消失。
谷歌搜索一无所获,有什么想法吗?这是绘制用户水龙头的代码。
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
swiped = YES;
UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:self.view];
currentPoint.y -= 20;
UIGraphicsBeginImageContext(self.view.frame.size);
[_drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5.0);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.0, 0.0, 0.0, 1.0);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
_drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
lastPoint = currentPoint;
}
【问题讨论】:
-
你试过使用 CGContextRef context = UIGraphicsGetCurrentContext();作为变量..并使用上下文代替 UIGraphicsGetCurrentContext().. ?
-
有趣...是的,让我试试
-
我尝试在 iOS8 中测试您的代码,它工作正常:/ .
-
您使用的是 iPad 2 吗?模拟器 ipad 2 和 ipad mini 设备都可以正常工作。但 ipad 2 设备本身会导致问题。
-
是的,我确实尝试过使用
Xcode Version 6.0.1 (6A317)和iPad 2 with iOS 8.0.2。你试过用UIBezierPath代替吗?
标签: ios objective-c uiimageview core-graphics