Con CGContextSetLineWidth(context, 1)
la anchura es casi alwayas al menos 2 píxeles en lugar 1CGContextSetLineWidth (contexto, 1) - el ancho es de casi alwayas al menos 2 píxeles en lugar 1
QQCandleStickLayer.m
-(id)init
{
self = [super init];
if(self != nil)
{
self.delegate = self;
self.opaque = NO;
}
return self;
}
- (void)drawLayer:(CALayer*)layer inContext:(CGContextRef)context{
CGContextSetLineWidth(context, 1.0f);
CGContextSetAllowsAntialiasing(context, false);
CGContextSetShouldAntialias(context, false);
CGContextSetInterpolationQuality(context,kCGInterpolationNone);
CGContextSetShadowWithColor(context, CGSizeMake(0.0, 0.0), 0, NULL);
CGContextMoveToPoint(context, self.bounds.origin.x+30.5f, self.bounds.origin.y+self.bounds.size.height-indent);
CGContextAddLineToPoint(context, self.bounds.origin.x+30.5f, self.bounds.origin.y+self.bounds.size.height-(self.bounds.size.height-lastY));
CGContextClosePath(context);
CGContextSetRGBStrokeColor(context, 119.0f/255, 119.0f/255, 119.0f/255, 1.0);
CGContextStrokePath(context);
}
QQDefluviumLayer. m
- (void)drawLayer:(CALayer*)layer inContext:(CGContextRef)context{
UIImage *myDefluvium = [UIImage imageNamed:@"delfluviumNewRotatedSmall.png"];
CGLayerRef layerCircle = CGLayerCreateWithContext(context, myDefluvium.size,NULL);
if (layerCircle)
{
CGContextRef layerContext = CGLayerGetContext(layerCircle);
CGContextDrawImage(layerContext, (CGRect){ CGPointZero, myDefluvium.size }, myDefluvium.CGImage);
CGContextDrawLayerInRect(context, CGRectMake(layer.bounds.origin.x,layer.bounds.origin.y, layer.bounds.size.width,layer.bounds.size.height), layerCircle);
CFRelease(layerCircle);
}
}
QuickQuoteViewController.m
defluviumLayer=[[QQDefluviumLayer alloc] init];
[defluviumLayer setBounds:CGRectMake(0, 0, 61, 343)];
[defluviumLayer setPosition:CGPointMake(277,246)];
[self.view.layer addSublayer:defluviumLayer];
[defluviumLayer update];
candleStickLayer=[[QQCandleStickLayer alloc] init];
[candleStickLayer setBounds:CGRectMake(0,0, defluviumLayer.frame.size.width, defluviumLayer.frame.size.height)];
[candleStickLayer setPosition:CGPointMake(defluviumLayer.position.x,defluviumLayer.position.y)];
[self.view.layer addSublayer:candleStickLayer];
[candleStickLayer update];
estoy dibujando en una CALayer, y tienen Image con la imagen debajo de la capa, como he probado - Si dibujo en clara vista blanco - la línea se puede extraer con un ancho de 1, pero no en la imagen
Una explicación relacionada: https://developer.mozilla.org/En/Canvas_tutorial/Applying_styles_and_colors#A_lineWidth_example – kennytm
CGContextSetLineWidth (context, 1.0f); \t CGContextSetAllowsAntialiasing (context, false); \t CGContextSetShouldAntialias (context, false); \t CGContextSetShadowWithColor (context, CGSizeMake (0.0, 0.0), 0, NULL); \t \t CGContextSetRGBStrokeColor (contexto, 119.0f/255, 119.0f/255, 119.0f/255, 1.0); \t CGContextMoveToPoint (context, self.bounds.origin.x + 30.5f, self.bounds.origin.y + self.bounds.size.height-indent); \t CGContextAddLineToPoint (context, self.bounds.origin.x + 30.5f, self.bounds.origin.y + self.bounds.size.height- (self.bounds.size.height-lastY)); \t CGContextClosePath (context); – freennnn
muchas gracias, pero desafortunadamente no me ayudó ( – freennnn