2012-08-25 96 views
1

嗨,有沒有什麼辦法可以用按鈕以編程方式更改顏色?在uidraw中更改顏色更改

>

-(void)drawToBuffer { 

//     Red Gr Blu Alpha 
CGFloat color[4] = {0.0, 0.0, 0.0, 1.0}; 


if (self.previousPoint != nil) { 
    CGContextSetRGBStrokeColor(offScreenBuffer, color[0], color[1], color[2], color[3]); 

    CGContextBeginPath(offScreenBuffer); 
    CGContextSetLineWidth(offScreenBuffer, 5.0); 
    CGContextSetLineCap(offScreenBuffer, kCGLineCapRound); 

    CGContextMoveToPoint(offScreenBuffer, previousPoint.location.x, previousPoint.location.y); 
    CGContextAddLineToPoint(offScreenBuffer, point.location.x, point.location.y); 

    CGContextDrawPath(offScreenBuffer, kCGPathStroke); 
} 

}

這屬於uidraw視圖和IM希望在我的應用程序

+0

它現在黑色我想把它改成白色,所以它會像橡皮擦 – Freedom4ever

回答

1

只是顏色值更改爲白色以創建一個UiDraw橡皮擦功能...即改變顏色[4] = {1.0,1.0,1.0,1.0}這是白色的... ...

顏色需要r,g,b,a作爲顏色分量範圍從0.0到1.0浮點值或1到int值爲255。組件a代表透明度。

+0

我知道我需要的是在應用程序運行時使用按鈕改變顏色 – Freedom4ever

+0

將所需的顏色作爲參數傳遞給以上功能爲按鈕 –

+0

的事件嘗試,測試和失敗 – Freedom4ever