我有iPhone 4S iOS 7.0.4 Jailbreak用戶的TestFlight崩潰日誌。在這條線上添加CGColorRef時CFArrayAppendValue崩潰
崩潰:
CFArrayAppendValue(colorArray, lighterColor);
在崩潰發生全法:
- (UIImage *) imageWithColor:(UIColor *)color_ Height:(CGFloat)height_ Retina:(BOOL)retina_
{
UIGraphicsBeginImageContextWithOptions(CGSizeMake(1.0f, height_), YES, retina_ ? 2.0f : 1.0f);
CFMutableArrayRef colorArray = CFArrayCreateMutable(NULL, 2, &kCFTypeArrayCallBacks);
CGColorRef lighterColor = CGColorRetain([[color_ lighterColor] CGColor]);
CGColorRef darkerColor = CGColorRetain([[color_ darkerColor] CGColor]);
CFArrayAppendValue(colorArray, lighterColor);
CFArrayAppendValue(colorArray, darkerColor);
CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
CGGradientRef gradient = CGGradientCreateWithColors(space, colorArray, NULL);
CGContextDrawLinearGradient(UIGraphicsGetCurrentContext(), gradient, CGPointMake(0.0f, 0.0f), CGPointMake(1.0f, height_), kCGGradientDrawsBeforeStartLocation);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
CGColorRelease(lighterColor);
CGColorRelease(darkerColor);
return image;
}
我很想知道如何處理這個問題。
任何幫助表示讚賞!
驗證'lighterColor'不是NULL,然後再將它添加到數組中。 – Emmanuel