嗨有什么办法可以用按钮以编程方式更改颜色吗?
>
-(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视图,我希望在我的应用程序中为UiDraw创建一个橡皮擦功能
答案 0 :(得分:1)
只需将颜色值更改为白色...即改变颜色[4] = {1.0,1.0,1.0,1.0},这是白色....
颜色取r,g,b,a作为颜色分量,浮点值范围为0.0到1.0,int值范围为1到255。组件a代表透明度。