Swift 注释

Apple官方关于文档注释的解释

附上一个例子

/// 初始化一个带边框的圆角按钮
///
/// - 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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 第一次写东西发布到网络上,还是有点小激动的。 不久之前加入了一个读书分享群。 里面很多人都说读了一定要总结出来,那...
    Aiden_Xi阅读 2,548评论 0 6
  • 转载自:https://github.com/Tim9Liu9/TimLiu-iOS[https://github...
    香橙柚子阅读 8,832评论 0 36
  • 时间似乎总是过得很快,在你感觉日子还很遥远的时候,艺博教育父母学院2阶段的教练课如期开课了!3天2晚的课程...
    陈妈阅读 523评论 0 2
  • 你好,朋友。此刻是北京时间12:08。列车上的背景乐,是陈奕迅的红玫瑰。 24寸的粉色行李箱。黑色尼龙质地的单肩包...
    似风追风阅读 666评论 7 2
  • 般若品 迷悟有迟疾(三) (三)只此见性门 这个见性法门的本身,是超越顿渐,超越迟疾,也打破了时间和空间的观念。禅...
    舞言阅读 467评论 0 0