我正在使用先前答案中的以下代码通过组合 UIImageView 和 UITextView 创建新的 UIImage。
UIView *parentView = [[UIView alloc] initWithFrame:CGRectZero];
[parentView addSubview:self.imagePreview];
[self.imagePreview setFrame:CGRectMake(0, 0, 100, 100)];
[parentView addSubview:self.memeTextFieldTop];
[self.memeTextFieldTop setFrame:CGRectMake(20, 20, 80, 20)];
[parentView sizeToFit];
UIGraphicsBeginImageContext([parentView bounds].size);
[[parentView layer] renderInContext:UIGraphicsGetCurrentContext()];
UIImage *outputImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
问题似乎是我目前遇到以下错误,我不确定如何解决它们。
<Error>: CGContextSaveGState: invalid context 0x0
<Error>: CGContextSetAlpha: invalid context 0x0
<Error>: CGContextSaveGState: invalid context 0x0
<Error>: CGContextGetBaseCTM: invalid context 0x0
<Error>: CGContextConcatCTM: invalid context 0x0
<Error>: CGContextSetBaseCTM: invalid context 0x0
<Error>: CGContextSaveGState: invalid context 0x0
<Error>: CGContextSetAlpha: invalid context 0x0
<Error>: CGContextSaveGState: invalid context 0x0
<Error>: CGContextConcatCTM: invalid context 0x0
任何想法如何解决这个问题?