0

I setup a view controller scene with interface builder. I add a view to my controller and add a custom class (CustomView) to it.

enter image description here

The view controller code

class ViewController: UIViewController {

    @IBOutlet var myCustomView: CustomView!
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    override func viewDidAppear(animated: Bool) {
        print(myCustomView.frame.origin)
    }

}

The question

Why the origin of myCustomView is equal to (-4.0, 64.0) and not (0, 64) ?

elyrico
  • 519
  • 6
  • 19

1 Answers1

1

when you add the constraints,your constraints to margin remains unchecked. Because of constraints to margin it gives you a frame that starts with (-4.0,64.0) like that...

Try to pinned all your edges without constraints to margin that will solve your problem ..

For more guide about constraints to margin, check this link

Community
  • 1
  • 1
Bhavin Bhadani
  • 22,224
  • 10
  • 78
  • 108