首页 > 解决方案 > 如何在 Swift 的 UIButton 扩展中使用 UIButton 实例作为参数创建函数?

问题描述

我有一些 UIButton 实例(按钮),并且还想为每个实例添加一个披露指示器。因此,我想创建一个辅助函数。但是,我不知道如何使用 UIButton 实例作为 UIButton 扩展中的参数来做到这一点。以下是我目前拥有的代码。

@IBOutlet weak var checkByDepartment: DesignableButton!

let disclosure = UITableViewCell()
disclosure.frame = checkByDepartment.bounds
disclosure.accessoryType = .disclosureIndicator
disclosure.isUserInteractionEnabled = false

checkByDepartment.addSubview(disclosure)

任何帮助,将不胜感激!

标签: iosswiftfunction

解决方案


推荐阅读