Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to change color of the brush on button click?
    primarykey
    data
    text
    <p>I am developing a paint app for my first try in iOS development.</p> <p>I am trying to make a color palette that will change my brush's color on button click but i don't know how. I already have UIButtons that are connected to its reference outlets and sent event but my codes are not working.</p> <p>here:</p> <pre><code> - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { touchSwiped = YES; redAmt = 0; blueAmt = 0; greenAmt = 0; UITouch *touch = [touches anyObject]; CGPoint currentTouch = [touch locationInView:self.view]; currentTouch.y -= 20; UIGraphicsBeginImageContext(self.view.frame.size); [touchDraw.image drawInRect:CGRectMake(0, 0, touchDraw.frame.size.width, touchDraw.frame.size.height)]; CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 35.0); CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), redAmt, blueAmt, greenAmt, 1.0); CGContextBeginPath(UIGraphicsGetCurrentContext()); CGContextMoveToPoint(UIGraphicsGetCurrentContext(), endingPoint.x, endingPoint.y); CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentTouch.x, currentTouch.y); CGContextStrokePath(UIGraphicsGetCurrentContext()); touchDraw.image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); endingPoint = currentTouch; touchMoved++; if (touchMoved == 10) { touchMoved = 0; } } -(IBAction)blackInk:(id)sender { redAmt = 0; blueAmt = 0; greenAmt = 0; } -(IBAction)blueInk:(id)sender { redAmt = 0; blueAmt = 0; greenAmt = 1; } -(IBAction)redInk:(id)sender { redAmt = 1; blueAmt = 1; greenAmt = 0; } -(IBAction)greenInk:(id)sender { redAmt = 0; blueAmt = 1; greenAmt = 0; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload