extension UIView { func addSubviewAndConstrain ( _ subview: UIView) -> Void { subview.frame = self .bounds subview.translatesAutoresizingMaskIntoConstraints = false subview.alpha = 1.0 self .addSubview(subview) NSLayoutConstraint.activate([ self .widthAnchor.constraint(equalTo: subview.widthAnchor, multiplier: 1.0 ), self .heightAnchor.constraint(equalTo: subview.heightAnchor, multiplier: 1.0 ), self .leadingAnchor.constraint(equalTo: subview.leadingAnchor), self .trailingAnchor.constraint(equalTo: subview.trailingAnchor), self .topAnchor.constraint(equalTo: subview.topAnchor), self .bottomAnchor.constraint(equalTo: subview.bottomAnchor) ]) } } That covers the basic need of showing my slides, making them look good, and easily navigating from one slide to the next or previous one.