2010-05-14 34 views
0

此代碼用於在我的應用程序中繪製。所以我有問題,如果我用alpha屬性= 1繪製。這是非常好的,但如果我改變alpha屬性= 0.2,那麼我的油漆不好。如何使alpha屬性= 0.2更好。在iPhone上使用alpha屬性<1.0的Quartz 2D繪製線條時發生的問題

http://www.flickr.com/photos/[email protected]/page1/

戰平的α= 1:這是很好 戰平阿爾法= 0.2:這是不好的

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { 
if ([self.view superview] && (headerView.frame.origin.y == -30)) { 
    mouseSwiped = YES; 

    UITouch *touch = [touches anyObject]; 
    CGPoint currentPoint = [touch locationInView:self.view]; 
    currentPoint.y -= 20; 



    UIGraphicsBeginImageContext(self.view.frame.size); 

    CGContextRef context = UIGraphicsGetCurrentContext(); 

    [drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; 
    CGContextSetLineCap(context, kCGLineCapRound); 
    CGContextSetLineWidth(context, currentBrushProperty.brushSize); 
    CGContextSetRGBStrokeColor(context, [self red], [self green], [self blue], currentBrushProperty.brushTransparency); 
    CGContextSetRGBStrokeColor(context, 1.0, 0.0, 0.0, 1.0); 

    CGContextBeginPath(context); 
    CGContextMoveToPoint(context, lastPoint.x, lastPoint.y); 
    CGContextAddLineToPoint(context, currentPoint.x, currentPoint.y); 

    CGContextStrokePath(context); 
    drawImage.image = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext(); 

    lastPoint = currentPoint; 

}} 

回答

0

你的問題是,你正在繪製系列半透明圓的 - 一個用於觸摸註冊的每個地點。最簡單的解決方案可能是使用100%alpha進行繪製,然後將彩色區域的alpha調整回所需的alpha。

相關問題