收到错误“:doClip:空路径。”上
CGContextClip(ctx);
当使用 Ahmet Ardal 的代码进行 UINavigationBar 自定义背景的自定义时。
理想情况下,我想解决此错误 - 它会阻止 Apple 的批准吗?
我的理解是它定义了要绘制的剪切区域。我已经将导航栏图形设置为正确的大小,因此理论上它们不需要被剪切。
因此注释掉了有问题的行。一切似乎都很棒,但担心它可能会产生我不知道的影响
下面是经过调整的代码,因此如果您有更深的横向栏(例如其中有分段控件),它就可以工作
- (void) drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
{
if ([self isMemberOfClass:[UINavigationBar class]] == NO) {
return;
}
//NSLog(@"NAV HEIGHT IS %f %f",self.frame.size.height, self.frame.size.width);
UIImage *image = nil;
if (self.frame.size.width > 320) {
if (self.frame.size.height > 32) {
// Deep NavBar
image = [UINavigationBar bgImageLandscapeDeep];
} else {
image = [UINavigationBar bgImageLandscape];
}
} else {
image = [UINavigationBar bgImagePortrait];
}
NSLog(@"CGContextClip produces <Error>: doClip: empty path. Path is %@",ctx);
//CGContextClip(ctx);
CGContextTranslateCTM(ctx, 0, image.size.height);
CGContextScaleCTM(ctx, 1.0, -1.0);
CGContextDrawImage(ctx, CGRectMake(0, 0, self.frame.size.width, self.frame.size.height), image.CGImage);
}
最佳答案
我继承了一个带有 drawLayer:inContext:
方法的应用程序,该方法调用 CGContextClip(...)
并生成“
将其提交给商店没有任何问题;我非常有信心该错误是无害的。
根据苹果的文档:
Parameters
c
A graphics context that contains a path. If the context does not have a current path, the function does nothing.
如果您确实想阻止记录错误,您可能应该在调用CGContextClip(...)
之前检查上下文:
if (!CGContextIsPathEmpty(c))
{
CGContextClip(c);
}
关于iphone - CGContextClip空路径错误(自定义UINavigationBar背景),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5982180/