CGContextRef currentContext = UIGraphicsGetCurrentContext();
UIGraphicsBeginImageContext(drawImage.frame.size);
[drawImage.image drawInRect:CGRectMake(0,0, drawImage.frame.size.width, drawImage.frame.size.height)];
CGContextSetRGBStrokeColor(currentContext, 0.0, 0.0, 0.0, 1.0);
UIBezierPath *path=[self pathFromPoint:currentPoint
toPoint:currentPoint];
CGContextBeginPath(currentContext);
CGContextAddPath(currentContext, path.CGPath);
CGContextDrawPath(currentContext, kCGPathFill);
drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
Trong mã ở trên CGContextRef currentContext
được tạo từ UIGraphicsGetCurrentContext()
và chuyển đến CGContextBeginPath CGContextAddPath CGContextDrawPath
currentContext có thông số với chúng không hoạt động đối với tôi! Khi tôi đang làm touchMovie
.UIGraphicsGetCurrentGiá trị văn bản truyền qua CGContextRef không hoạt động?
Khi tôi chuyển trực tiếp UIGraphicsGetCurrentContext()
thay cho số currentContext
làm việc cho tôi. Tôi muốn biết tại sao lại như thế?
@Tất cả hãy tư vấn cho tôi về vấn đề này.
Hơn nữa, bạn nên kết thúc ngữ cảnh hình ảnh khi không cần đến nữa để khôi phục ngăn xếp đồ họa ở trạng thái trước đó: 'UIGraphicsEndImageContext();' –
@Sch làm việc cho tôi Cảm ơn Sch – kiran
tôi tìm thấy một vấn đề khác về điều này! tôi không thể thiết lập màu cho CGContextSetRGBStrokeColor này (currentContext, 1.0, 0.0, 0.0, 1.0); nếu tôi đặt nó thành màu đỏ thì nó vẫn vẽ màu đen! – kiran