2

当我调用 drawAtPoint 时,我偶尔会得到一个 exc_bad_access。奇怪的是它并不总是发生,通常在多次调用此方法之后。可能是什么问题?

- (UIImage *)createImage {
  NSString *testString = @"Test";
  UIFont *font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]];

  CGSize size = CGSizeMake(256, 256);

  UIGraphicsBeginImageContextWithOptions(size, NO, 0.0);

  [testString drawAtPoint:CGPointMake(0.0, 0.0) withFont:font];
  UIImage *image = UIGraphicsGetImageFromCurrentImageContext();


  UIGraphicsEndImageContext();

  return image;
}
4

0 回答 0