में एक पेंट ऐप के लिए इरेज़र टूल बनाना मैं एक पेंट ऐप बना रहा हूं और मैं जानना चाहता हूं कि इरेज़र टूल को कैसे कार्यान्वित किया जाए। मैं अपने इरेज़र उपकरण को सफेद रंग पेंट करने के लिए नहीं चाहता क्योंकि मैं उपयोगकर्ताओं को पृष्ठभूमि रंग बदलने की अनुमति देना चाहता हूं। और, क्या ब्रश की कठोरता को सेट करना संभव है? यदि हाँ, कृपया मुझे बताएं कि कैसे।आईओएस
धन्यवाद
यहाँ मैं अब तक क्या किया है है:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
lastPoint = [touch locationInView:self.view];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:self.view];
UIGraphicsBeginImageContext(self.view.frame.size);
[drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 10);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.0, 0.0, 0.0, 1.0);
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
lastPoint = currentPoint;
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:self.view];
UIGraphicsBeginImageContext(self.view.frame.size);
[drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 10);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.0, 0.0, 0.0, 1.0);
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
lastPoint = currentPoint;
}
- (IBAction)clear:(id)sender {
drawImage.image = nil;
}
यह एक दिलचस्प सवाल यह है कि प्राप्त करने के लिए लिया, लेकिन मुझे लगता है कि आप इसे एक बहुत स्पष्ट कर सकता है। हमें अभी तक बताएं कि आपके पास क्या है; शायद कुछ कोड शामिल करें। – jtbandes
@jtbandes मैंने कोड –
जोड़ा है कृपया इस लिंक को देखें और मेरा उत्तर देखें http://stackoverflow.com/questions/3863931/want-to-add-manual-erasing-option-in-ipad-painting- एप्लिकेशन-बाय-क्वार्ट्ज/12797513 # 12797513 –