私はこのコードを手に入れました:
CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB();
CGFloat colors[] = {
1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f,
};
CGGradientRef gradientRef = CGGradientCreateWithColorComponents(rgb, colors, NULL, sizeof(colors) / (sizeof(colors[0]) * 4));
CGColorSpaceRelease(rgb);
CGContextRef context = UIGraphicsGetCurrentContext();
CGRect rect = theCell.backgroundView.bounds;
CGPoint start = CGPointMake(rect.origin.x, 0);
CGPoint end = CGPointMake(rect.origin.x, rect.size.height/2);
CGContextDrawLinearGradient(context, gradientRef, start, end, kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation);
そして、指定されたビューに描画し、クリッピング四角形をパラメーターで関数に渡すにはどうすればよいのだろうか。ヒント: drawRect については気にしません。何もサブクラス化していません。
ヒント 2: 後で削除できないレイヤーを挿入したくありません。
ヒント 3: このコードでは、私の目に見えるものは何も描画されません..... :-( グラフィック ポートがありませんか?
ヒント 4: 背景色を変更するだけで描画を消去したいのですが、完了です...