1

I am drawing bubble using core graphics in my application.Now i want to set gradient color effect to my bubble.i can give radial effect to that bubble. but i want to set something different king of gradient effect.Here is my code using radial gradient :

    CGGradientRef gradient;
    CGColorSpaceRef colorSpace;
    CGFloat locations[] = {0.0,1.0};
    CGFloat components[] = { red2,green2,blue2,1.0,red1,green1,blue1,1.0  };
    colorSpace = CGColorSpaceCreateDeviceRGB();
    gradient = CGGradientCreateWithColorComponents(colorSpace,components,locations,
                                                   sizeof(locations)/sizeof(CGFloat));
    CGPoint start = CGPointMake(self.bounds.size.width/2, self.bounds.size.height/2 ), end = CGPointMake(self.bounds.size.width/2 , self.bounds.size.height/2);
    CGFloat startRadius = 0.0, endRadius = radius - borderWidth;
    CGContextDrawRadialGradient(contextRef,gradient,start,startRadius,end,endRadius,0);
    CGGradientRelease(gradient);
    CGColorSpaceRelease(colorSpace);

I have attached image here ,like that i want gradient colour.Please help me.Thanking you.enter image description here

Nitin Gohel
  • 49,482
  • 17
  • 105
  • 144
h999
  • 395
  • 1
  • 5
  • 21
  • That does not look like a standard color gradient at all. – Jongware Sep 02 '13 at 06:35
  • take a look this i m sure this helps you :- http://stackoverflow.com/questions/11614162/ios-images-in-a-bubble-effect – Nitin Gohel Sep 02 '13 at 06:35
  • @Jongware so what should i do according to your answer?should i use something else instead of gradient colour? – h999 Sep 02 '13 at 06:47
  • Scratch the idea of drawing something like this with a simple gradient. You can either look in to *procedurally* drawing it (decompose the image in separate objects, each of which *are* drawable with basic commands), or make a mask for this image and draw it as a transparent bitmap. – Jongware Sep 02 '13 at 08:49

0 Answers0