center uiview programmatically - swift code example
Example 1: how to set the center in view in swift
childView.centerXAnchor.constraint(equalTo: parentView.centerXAnchor).isActive = true
childView.centerYAnchor.constraint(equalTo: parentView.centerYAnchor).isActive = true
Example 2: how to set the center in view in swift
childView.center = parentView.center