-2
class ViewController: UIViewController {

    @IBOutlet var labels: [UILabel]!


    override func viewDidLoad() {
        super.viewDidLoad()


        labels[0].layer.borderWidth = 1
        labels[0].layer.borderColor = UIColor.black.cgColor
    }
}
Kamran
  • 14,987
  • 4
  • 33
  • 51
Vu Tran
  • 11
  • 2

1 Answers1

3

You can loop through the labels and set the border as below,

labels.forEach { (label) in
    label.layer.borderColor = UIColor.black.cgColor
    label.layer.borderWidth = 1.0
}
Kamran
  • 14,987
  • 4
  • 33
  • 51