6
Ben ios özelliğini çizim geliştiriyorum
3 türü var çalışır DOTTED satırları DOTTED satırları ile sorun, hızlı çizerim, iyi çizer ama yavaşça çizdiğimde
, ben hatlarıNoktalı çizgi değil yavaş yavaş
- noktalı
kesik DÜZLEM
Bellow, kod parçacığıdır, lütfen bana sorun nerede yol göstersin. İçinde
- (void)drawingLayerMoved:(UIPanGestureRecognizer *)recognizer {
//MOVE START
if (recognizer.state == UIGestureRecognizerStateBegan) {
dw_mouseSwiped = NO;
dw_lastPoint = [recognizer locationInView:self.tempDrawImage];
UIGraphicsBeginImageContext(self.tempDrawImage.frame.size);
[self.tempDrawImage.image drawInRect:CGRectMake(0, 0, self.tempDrawImage.frame.size.width, self.tempDrawImage.frame.size.height)];
}
//MOVING
else if (recognizer.state == UIGestureRecognizerStateChanged) {
dw_mouseSwiped = YES;
CGPoint currentPoint = [recognizer locationInView:self.tempDrawImage];
CGContextRef dw_context = UIGraphicsGetCurrentContext();
if([dw_brushType isEqual: DRAWING_DOTTED_LINE]) {
CGContextSetLineCap(dw_context, kCGLineCapRound);
}
else if([dw_brushType isEqual: DRAWING_DASHED_LINE]) {
CGContextSetLineCap(dw_context, kCGLineCapSquare);
}
else if([dw_brushType isEqual: DRAWING_PLANE_LINE] ) {
CGContextSetLineCap(dw_context, kCGLineCapRound);
}
// ADD FEW SPACES B/W DOTS OF LINE
if([dw_brushType isEqual: DRAWING_DASHED_LINE] || [dw_brushType isEqual: DRAWING_DOTTED_LINE]) {
CGFloat dw_dash[] = {2,dw_brush*3,dw_brush*2,dw_brush};
CGContextSetLineDash(dw_context, 1, dw_dash, 4);
}
//BRUSH WIDTH (we have devided it on 3)
CGContextSetLineWidth(dw_context, (dw_brush/3));
if([dw_drawingLayerMode isEqualToString:DRAWING_LAYER_MODE_ERASER]){
//BRUSH CLEAR COLOR
CGContextSetFillColorWithColor(dw_context, [UIColor clearColor].CGColor);
//CLEAR DRAWING
CGContextSetBlendMode(dw_context, kCGBlendModeClear);
} else{
// BRUSH RGB COLOR
CGContextSetRGBStrokeColor(dw_context, dw_red, dw_green, dw_blue, dw_opacity);
//NORMAL DRAWING
CGContextSetBlendMode(dw_context,kCGBlendModeNormal);
}
CGContextMoveToPoint(dw_context, dw_lastPoint.x, dw_lastPoint.y);
CGContextAddLineToPoint(dw_context, currentPoint.x, currentPoint.y);
CGContextStrokePath(dw_context);
//SAVE CURRENT MOVE INFO IN TEMP IMG
self.tempDrawImage.image = UIGraphicsGetImageFromCurrentImageContext();
//SAVE CURRENT MOVE POINT AS dw_lastPoint
dw_lastPoint = currentPoint;
}
//MOVE END
else if (recognizer.state == UIGestureRecognizerStateEnded) {
UIGraphicsEndImageContext();
}
}
Benim sorunum bu soru gibi simmiler olmakla bulundu vermedi çözüm: Ben sorunu çözüldü Drawing a dashed line with CGContextSetLineDash
Çizgiyi değiştirmek isterseniz, her değişiklik için bir görüntünün yol çizme yaklaşımı çalışmaz. Aynı değişebilir yola eklemeniz ve yeniden çizmeniz gerekecektir. –
@ DavidRönnqvist, kodu yazarken bana yardımcı olabilirseniz harika olurdu, çok aradım ama herhangi bir çözüm bulamadım –