से बाहर निकलने का कोई तरीका है drawRect:
वर्तमान ताज़ा किए बिना UIView
? उदाहरण के लिए:
- (void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(context, 1.0, 1.0, 1.0, 1.0);
CGContextSetLineWidth(context, 2);
CGContextMoveToPoint(context, 10.0, 30.0);
CGContextAddLineToPoint(context, 310.0, 30.0);
CGContextStrokePath(context);
//I would like to return from here and rollback all changes in drawRect:
}
धन्यवाद!
उत्तर:
जवाब के लिए 0 № 1यदि आपने संदर्भ में चित्रण शुरू नहीं किया है, तो बस से वापस जाना संभव हो सकता है drawRect:
। आपको "सेट करना होगा clearsContextBeforeDrawing
पहले देखने के लिए संपत्ति की संपत्ति।
संदर्भ में आकर्षित करने के बाद, दृश्य / परत हमेशा अपनी सामग्री अपडेट करेगी।