(_:for:)
语法在draw
文本之后是什么意思?特别是下划线和 for
。我假设这两个冒号是为了表示该方法有两个参数。
我刚刚从 https://developer.apple.com/documentation/uikit/uiview/1621844-draw 中选择了这个方法作为示例
此外,还有一个方法 draw(_:)
,它与 draw(_:for:)
有何不同?
这是来自 https://developer.apple.com/documentation/uikit/uiview/1622529-draw
我无法通过阅读文档清楚地辨别出哪些差异。
1- draw(_:for:)
Implemented to draw the view’s content for printing.
2- draw(_:)
Draws the receiver’s image within the passed-in rectangle.
1- _ 是参数标签,当参数存在时,调用方法时不需要传递参数名称
e.x
func goTo(value:Int) // call goTo(value:5)
func goTo(_ value:Int) // call goTo(5)
2- 冒号: 将parameterName 与parameterType 分隔开
paramterName:parameterType