附上一個例子
/// 初始化一個帶邊框的圓角按鈕
///
/// - parameter button: 需要設置的按鈕 類是引用類型
/// - parameter conerRadius: 圓角半徑
/// - parameter borderWith: 邊框寬度
/// - parameter tintColor: 邊框以及文字顏色
func initButton(button: UIButton, conerRadius: CGFloat, borderWith: CGFloat, tintColor: UIColor) {
button.titleLabel?.tintColor = tintColor
button.layer.masksToBounds = true
button.layer.cornerRadius = conerRadius
button.layer.borderWidth = borderWith
button.layer.borderColor = tintColor.CGColor
}
參數多的時候就可以用 - parameters
/// 初始化一個帶邊框的圓角按鈕
///
/// - parameters:
/// - button: 需要設置的按鈕 類是引用類型
/// - conerRadius: 圓角半徑
/// - borderWith: 邊框寬度
/// - tintColor: 邊框以及文字顏色
Swift 里的文檔注釋采用了Markdown
關鍵詞列
關鍵詞大小寫都可以
- Attention: Watch out for this!
- Author: Tim Cook
- Authors:
John Doe
Mary Jones
- Bug: This may not work
- Complexity: O(log n) probably
- Copyright: 2016 Acme
- Date: Jan 1, 2016
- experiment: give it a try
- important: know this
- invariant: something
- Note: Blah blah blah
- Precondition: alpha should not be nil
- Postcondition: happy
- Remark: something else
- Requires: iOS 9
- seealso: something else
- Since: iOS 9
- Todo: make it faster
- Version: 1.0.0
- Warning: Don't do it