J'ai écrit un dessin simple avec l'intention de dessiner un cercle, déposer une ombre et le remplir de bleu. J'ai réussi à dessiner un cercle et à le remplir en bleu mais mon ombre n'est pas en vigueur. Au lieu de remplir si je caresse mon cercle, je vois l'ombre est à l'intérieur du cercle et pendant le remplissage il est dessiné par la couleur de remplissageCore Graphics - Shadow not seen
directement à mon drawRect a dimension [[CustomButton alloc] initWithFrame: CGRectMake (0, 0, 50, 50)];
@implementation CustomButton
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
[self setBackgroundColor:[UIColor clearColor]];
}
return self;
}
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGColorRef colorRef = [[UIColor blueColor] CGColor];
CGContextSetStrokeColorWithColor(context, colorRef);
CGContextSetFillColorWithColor(context, [[UIColor blueColor] CGColor]);
CGRect buttonRect = CGRectInset(rect, 3, 3);
CGPoint centerPoint = CGPointMake(CGRectGetMidX(buttonRect ), CGRectGetMidY(buttonRect));
CGFloat radius = CGRectGetWidth(buttonRect)/2;
CGContextSaveGState(context);
CGContextSetShadow(context, CGSizeMake(15.0, 20.0), 1.0);
CGContextAddArc(context, centerPoint.x, centerPoint.y, radius, 0, 2*M_PI, 1);
CGContextClip(context);
CGContextFillRect(context, buttonRect);
CGContextRestoreGState(context);
CGColorRelease(colorRef);
}
@end
Merci
Il a travaillé. Je vous remercie. – slysid