テーブルのセルをカスタマイズして、2つの透明なストリップを作成する必要があります。1つはUITableViewCellの上端に対応し、もう1つは下端に対応します。これらのストリップは、下のビューの色(明るい黄色)を確認するために透明である必要があります。UITableViewCellのサブクラスを作成し、ストリップを描画するためのメソッドLayoutSubviews()を作成しましたが、間違っていますか?このエラーが発生します:
<Error>: CGContextBeginPath: invalid context 0x0
<Error>: CGContextMoveToPoint: invalid context 0x0
<Error>: CGContextAddLineToPoint: invalid context 0x0
<Error>: CGContextSetLineWidth: invalid context 0x0
<Error>: CGContextSetFillColorWithColor: invalid context 0x0
<Error>: CGContextMoveToPoint: invalid context 0x0
<Error>: CGContextAddLineToPoint: invalid context 0x0
<Error>: CGContextSetLineWidth: invalid context 0x0
<Error>: CGContextSetFillColorWithColor: invalid context 0x0
これはCustomCell.mのコードです:
-(void) layoutSubviews{
[super layoutSubviews];
CGContextRef ctxt = UIGraphicsGetCurrentContext();
CGContextBeginPath(ctxt);
CGContextMoveToPoint(ctxt, self.bounds.origin.x, self.bounds.origin.y);
CGContextAddLineToPoint(ctxt, self.bounds.size.width, self.bounds.origin.y);
CGContextSetLineWidth(ctxt, 5);
CGContextSetFillColorWithColor(ctxt, [UIColor clearColor].CGColor);
CGContextMoveToPoint(ctxt, self.bounds.origin.x, self.bounds.size.height);
CGContextAddLineToPoint(ctxt, self.bounds.size.width, self.bounds.size.height);
CGContextSetLineWidth(ctxt, 5);
CGContextSetFillColorWithColor(ctxt, [UIColor clearColor].CGColor);
CGContextStrokePath(ctxt);
}