में drawRect ओवरराइड करते हैं तो मैं अपने UIScrolLView में drawRect को ओवरराइड करने का प्रयास कर रहा हूं, हालांकि यह मुझे मेरे UIScrollView के लिए निर्दिष्ट पृष्ठभूमि रंग की बजाय यह काला पृष्ठभूमि देता है। ऐसा क्यों है? अगर मैं drawRect कोड को दूर तो सब कुछ ठीक है:ब्लैक बैकग्राउंड जब UIScrollView
- (void)drawRect:(CGRect)rect
{
[super drawRect:rect];
if (shouldDrawVerticalLineForProfile){
CGContextRef context = UIGraphicsGetCurrentContext();
CGColorRef separatorColor = [UIColor colorWithRed:47.0/255.0 green:47.0/255.0
blue:47.0/255.0 alpha:1.0].CGColor;
// Add at bottom
CGPoint startPoint = CGPointMake(60, 0);
CGPoint endPoint = CGPointMake(60, 10000);
CGContextSaveGState(context);
CGContextSetLineCap(context, kCGLineCapSquare);
CGContextSetStrokeColorWithColor(context, separatorColor);
CGContextSetLineWidth(context, 5.0);
CGContextMoveToPoint(context, startPoint.x + 0.5, startPoint.y + 0.5);
CGContextAddLineToPoint(context, endPoint.x + 0.5, endPoint.y + 0.5);
CGContextStrokePath(context);
CGContextRestoreGState(context);
}
}
मुझे लगता है कि पृष्ठभूमि रंग संपत्ति बस एक CGContextAddRect और CGContextFillPath, लपेटता है जो यदि आप ऐसा ही कुछ कार्य करें: यह करने के लिए सबसे सही तरीका निम्नलिखित
drawRect:
टेम्पलेट का उपयोग करने के लिए है? –कुछ ऐसा क्या करते हैं? – xonegirlz
ऊपर वर्णित दो कार्यों का उपयोग करके मैन्युअल रूप से bgcolor ड्राइंग। –