Я не уверен, как ваши цвета оборачиваются массивом цветов.
Попробуйте использовать
CGGradientCreateWithColorComponents(rgbColorspace, components, locations, num_locations);
вместо этого.
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextClearRect(ctx, rect);
CGFloat c = BUBBLE_INSET + BUBBLE_CORNER_RADIUS;
CGContextMoveToPoint(ctx, BUBBLE_INSET, c);
CGContextAddArcToPoint(ctx, BUBBLE_INSET, BUBBLE_INSET, c, BUBBLE_INSET, BUBBLE_CORNER_RADIUS);
CGContextAddLineToPoint(ctx, rect.size.width - c, BUBBLE_INSET);
CGContextAddArcToPoint(ctx, rect.size.width - BUBBLE_INSET, BUBBLE_INSET, rect.size.width - BUBBLE_INSET, c, BUBBLE_CORNER_RADIUS);
CGContextAddLineToPoint(ctx, rect.size.width - BUBBLE_INSET, rect.size.height - c);
CGContextAddArcToPoint(ctx, rect.size.width - BUBBLE_INSET, rect.size.height - BUBBLE_INSET, rect.size.width - c, rect.size.height - BUBBLE_INSET, BUBBLE_CORNER_RADIUS);
CGContextAddLineToPoint(ctx, c, rect.size.height - BUBBLE_INSET);
CGContextAddArcToPoint(ctx, BUBBLE_INSET, rect.size.height - BUBBLE_INSET, BUBBLE_INSET, rect.size.height - c, BUBBLE_CORNER_RADIUS);
CGContextClosePath(ctx);
CGContextClip(ctx);
CGGradientRef gradient;
CGColorSpaceRef rgbColorspace;
size_t num_locations = 2;
CGFloat locations[2] = { 0.0, 1.0 };
CGFloat components[8] = { 1.0, 0.0, 0.0, 1.0, // Start color
1.0, 1.0, 1.0, 0.65 }; // End color
rgbColorspace = CGColorSpaceCreateDeviceRGB();
gradient = CGGradientCreateWithColorComponents(rgbColorspace, components, locations, num_locations);
CGPoint p1 = CGPointMake(CGRectGetMidX(rect), CGRectGetMinY(rect));
CGPoint p2 = CGPointMake(CGRectGetMidX(rect), CGRectGetMaxY(rect));
CGContextDrawLinearGradient(ctx, gradient, p1, p2, 0);
CGGradientRelease(gradient);
Вы получите это:
смещение было 5,0
радиус был 10,0
![enter image description here](https://i.stack.imgur.com/QY7H3.png)