小编ard*_*a30的帖子

如何在iOS中以最佳方式创建自定义按钮并多次使用?

UIButton在ios中创建了一个自定义。我想使用相同的自定义按钮十次,它们具有相同的属性但标题不同。在不为每个按钮重复相同代码的情况下,最有效,最聪明的方法是什么?它应该是结构还是类还是其他?我该如何实施?我为自定义按钮更改的属性如下:

 @IBOutlet weak var button_1: UIButton!

 button_1.frame = CGRectMake(0.0, 0.0, button_1.frame.width, button_1.frame.height)
 button_1.clipsToBounds = true
 button_1.layer.cornerRadius = button_1.frame.width/2.0
 button_1.layer.borderColor = UIColor.whiteColor().CGColor
 button_1.layer.borderWidth=2.0
Run Code Online (Sandbox Code Playgroud)

button ios swift

3
推荐指数
2
解决办法
7655
查看次数

标签 统计

button ×1

ios ×1

swift ×1