CGContextStrokePath triggers EXC_BAD_ACCESS in iOS > 5 [duplicate]
This question already has an answer here: Assigning an existing CGColor to a CGColor property works in iOS Simulator, not iOS device. Why? 3 answers I have a custom UIButton class that adds a gradient and a gloss effect to the UIButton the code works perfectly in iOS 4 and on iOS5 simulator but when i run it on iOS 5 devices it gives me the exception EXC_BAD_ACCESS , the exception is triggered by the line : CGContextStrokePath(context); any help is really appreciated , here's my code - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGFloat actualBrightness