4

I had a code snippet as shown below that used to work just fine until I migrated to Swift 3, to be able to draw a border around the UIView. I just want to be able to do this at the bottom of the UIView.

    let border = CALayer()
    border.frame = CGRect(x: 0, y: self.basicDetailsView.frame.height - 2, width: self.basicDetailsView.frame.width, height: 2)
    border.backgroundColor = UIColor.gray().cgColor

    self.basicDetailsView.layer.addSublayer(border)
Wyetro
  • 8,439
  • 9
  • 46
  • 64
EmbCoder
  • 562
  • 1
  • 7
  • 16

1 Answers1

2

I had similar problems performing calculations with frame sizes in viewDidLoad and awakeFromNib. Everything worked dandily in swift 2.3 and then things disappeared in swift 3

This post helped me: cornerRadius stopped working in Swift 2.3 / iOS 10 / Xcode 8

You can move the code to viewDidAppear, or call self.view.layoutIfNeeded() beforehand

I opted for the latter.

Gene Bo
  • 11,284
  • 8
  • 90
  • 137
Kate
  • 246
  • 2
  • 6