【发布时间】:2020-05-25 18:50:33
【问题描述】:
我正在尝试使用 Swift 5 填充 UIBezierPath,但是当我尝试运行我的函数来为路径着色时,我遇到了很多错误。它们都不是致命的,因此构建成功,但路径未绘制在屏幕上。我附上了相关代码和两个错误。提前致谢。
func colorPaths() {
let path = leftCorner //Where leftCorner isa UIBezierPath
let fillColor = UIColor.white
fillColor.setFill()
path.lineWidth = 1.0
let strokeColor = UIColor.blue
strokeColor.setStroke()
path.fill()
path.stroke()
}
错误:
2020-05-25 14:35:26.653308-0400 StatsApTBD[50679:10052723] [Unknown process name] CGContextSetFillColorWithColor: invalid context 0x0. Backtrace:
<$s10StatsApTBD8HeatViewC08changeToD4MapsyyF10colorPathsL_yyF+94>
<$s10StatsApTBD8HeatViewC08changeToD4MapsyyF+5247>
<$s10StatsApTBD8HeatViewC8addMarksyyF+626>
<$s10StatsApTBD8HeatViewC21viewDidLayoutSubviewsyyF+7831>
<$s10StatsApTBD8HeatViewC21viewDidLayoutSubviewsyyFTo+43>
<-[UIView(CALayerDelegate) layoutSublayersOfLayer:]+3013>
<-[CALayer layoutSublayers]+255>
<_ZN2CA5Layer16layout_if_neededEPNS_11TransactionE+517>
<_ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE+80>
<_ZN2CA7Context18commit_transactionEPNS_11TransactionEd+324>
<_ZN2CA11Transaction6commitEv+643>
<_afterCACommitHandler+160>
<__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__+23>
<__CFRunLoopDoObservers+430>
<__CFRunLoopRun+1514>
<CFRunLoopRunSpecific+438>
<GSEventRunModal+65>
<UIApplicationMain+1621>
<main+75>
<start+1> 1
2020-05-25 14:35:26.655966-0400 StatsApTBD[50679:10052723] [Unknown process name] CGContextSetStrokeColorWithColor: invalid context 0x0. Backtrace:
<$s10StatsApTBD8HeatViewC08changeToD4MapsyyF10colorPathsL_yyF+175>
<$s10StatsApTBD8HeatViewC08changeToD4MapsyyF+5247>
<$s10StatsApTBD8HeatViewC8addMarksyyF+626>
<$s10StatsApTBD8HeatViewC21viewDidLayoutSubviewsyyF+7831>
<$s10StatsApTBD8HeatViewC21viewDidLayoutSubviewsyyFTo+43>
<-[UIView(CALayerDelegate) layoutSublayersOfLayer:]+3013>
<-[CALayer layoutSublayers]+255>
<_ZN2CA5Layer16layout_if_neededEPNS_11TransactionE+517>
<_ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE+80>
<_ZN2CA7Context18commit_transactionEPNS_11TransactionEd+324>
<_ZN2CA11Transaction6commitEv+643>
<_afterCACommitHandler+160>
<__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__+23>
<__CFRunLoopDoObservers+430>
<__CFRunLoopRun+1514>
<CFRunLoopRunSpecific+438>
<GSEventRunModal+65>
<UIApplicationMain+1621>
<main+75>
<start+1> 1
【问题讨论】:
标签: swift xcode uibezierpath