how to set the center in view in swift

Swift
childView.centerXAnchor.constraint(equalTo: parentView.centerXAnchor).isActive = true
childView.centerYAnchor.constraint(equalTo: parentView.centerYAnchor).isActive = truechildView.center = parentView.center
Source

Also in Swift: