
我试过移动[path closePath];低于这4行,但它不会改变任何东西.我还在第一行之前设置了一个断点,并逐行手动完成了这个功能,而这只是造成严重破坏的4行.
对于这个问题似乎是一个趋势,一切都完全按照它应该呈现,但它会使控制台充满这些类型的消息.
任何帮助将不胜感激,我很乐意提供更多信息和更新.
功能:
-(CAShapeLayer *)lineBetweenPoint:(CGPoint)start andPoint:(CGPoint)end { //Draw the first circle UIBezIErPath *path = [UIBezIErPath bezIErPathWithArcCenter:start radius:klineEndRadius startAngle:0 endAngle:degrees_TO_radians(360) clockwise:TRUE]; //Add the line [path movetoPoint:start]; [path addlinetoPoint:end]; [path movetoPoint:end]; //Draw the second circle [path addArcWithCenter:end radius:klineEndRadius startAngle:0 endAngle:degrees_TO_radians(360) clockwise:TRUE]; //Close the path and set the coloring [path closePath]; /*The following 4 lines cause problems*/ [[UIcolor bluecolor] setstroke]; /*CAUSES PROBLEM*/ [[UIcolor bluecolor] setFill]; /*CAUSES PROBLEM*/ [path stroke]; /*CAUSES PROBLEM*/ [path fill]; /*CAUSES PROBLEM*/ //Create a shape layer CAShapeLayer *shapeLayer = [CAShapeLayer layer]; shapeLayer.path = [path CGPath]; shapeLayer.strokecolor = [klinecolor CGcolor]; shapeLayer.linewidth = klinewidth; shapeLayer.fillcolor = [klinecolor CGcolor]; //Return the layer return shapeLayer;} 日志输出:
解决方法@H_502_85@ 你正在混合你的API.当您使用CAShapeLayer时,您实际上并不自己进行绘图,只需配置对象并让CoreAnimation渲染服务器执行绘图.使用CoreGraphics,您可以在进程中绘制CGContextRef.你在这里的问题是需要创建CGContextRef(在[UIVIEw drawRect:]中自动发生).你可以使用UIGraphicsBeginImageContext中的一个来做…通常,但在这里你实际上并不想要CG,你想要CA.因此,只需省略这四行并确保您的CAShapeLayer配置正确,您就会很好. 总结: CGContextSetstrokecolorWithcolor: invalID context 0x0. This
is a serIoUs error. This application,or a library it uses,is using
an invalID context and is thereby contributing to an overall
degradation of system stability and reliability. This notice is a
courtesy: please fix this problem. It will become a Fatal error in an
upcoming update.: CGContextSetFillcolorWithcolor: invalID context 0x0. This is
a serIoUs error. This application,is using an
invalID context and is thereby contributing to an overall degradation
of system stability and reliability. This notice is a courtesy: please
fix this problem. It will become a Fatal error in an upcoming update.: CGContextSaveGState: invalID context 0x0. This is a serIoUs
error. This application,is using an invalID
context and is thereby contributing to an overall degradation of
system stability and reliability. This notice is a courtesy: please
fix this problem. It will become a Fatal error in an upcoming update.: CGContextSetlinewidth: invalID context 0x0. This is a serIoUs
error. This application,is using an invalID
context and is thereby contributing to an overall degradation of
system stability and reliability. This notice is a courtesy: please
fix this problem. It will become a Fatal error in an upcoming update.: CGContextSetlineJoin: invalID context 0x0. This is a serIoUs
error. This application,is using an invalID
context and is thereby contributing to an overall degradation of
system stability and reliability. This notice is a courtesy: please
fix this problem. It will become a Fatal error in an upcoming update.: CGContextSetlineCap: invalID context 0x0. This is a serIoUs
error. This application,is using an invalID
context and is thereby contributing to an overall degradation of
system stability and reliability. This notice is a courtesy: please
fix this problem. It will become a Fatal error in an upcoming update.: CGContextSetMiterlimit: invalID context 0x0. This is a
serIoUs error. This application,is using an
invalID context and is thereby contributing to an overall degradation
of system stability and reliability. This notice is a courtesy: please
fix this problem. It will become a Fatal error in an upcoming update.: CGContextSetFlatness: invalID context 0x0. This is a serIoUs
error. This application,is using an invalID
context and is thereby contributing to an overall degradation of
system stability and reliability. This notice is a courtesy: please
fix this problem. It will become a Fatal error in an upcoming update.: CGContextAddpath: invalID context 0x0. This is a serIoUs
error. This application,is using an invalID
context and is thereby contributing to an overall degradation of
system stability and reliability. This notice is a courtesy: please
fix this problem. It will become a Fatal error in an upcoming update.: CGContextDrawPath: invalID context 0x0. This is a serIoUs
error. This application,is using an invalID
context and is thereby contributing to an overall degradation of
system stability and reliability. This notice is a courtesy: please
fix this problem. It will become a Fatal error in an upcoming update.: CGContextRestoreGState: invalID context 0x0. This is a
serIoUs error. This application,is using an
invalID context and is thereby contributing to an overall degradation
of system stability and reliability. This notice is a courtesy: please
fix this problem. It will become a Fatal error in an upcoming update.
以上是内存溢出为你收集整理的ios – 使用UIBezierPath和CAShapeLayer时的“无效上下文0x0”全部内容,希望文章能够帮你解决ios – 使用UIBezierPath和CAShapeLayer时的“无效上下文0x0”所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)