Search code examples
ioscocoa-touchuikitcore-graphicsblending

Disable blending of UIView with its superview


I am creating say a rectangle in coregraphics - using CGContext functions in the - (void)drawRect:(CGRect)rect method of UIView and adding it to a superview. When i change the background of the superview , the color of the UIView blends with it. I want to disable this blending.


Solution

  • With some exploration( QuartzDemo Code of Apple) i finally found the answer to my problem. The color of the UIView was filled using [UIcolor color with R:G:B:Alpha] and the alpha was not 1.0.

    Also i used CGContextSetBlendMode(context, kCGBlendModeNormal);