So I have a UIImageView
named currentEventImage
that is inside an UIView
blurryBackGround
. I currently want to center the UIImageView
in the UIView
. Below is my current code
//Subviews will be added here
view.addSubview(blurryBackGround)
view.addSubview(currentEventImage)
view.addSubview(currentEventDate)
//Constraints will be added here
_ = blurryBackGround.anchor(top: view.topAnchor, left: view.leftAnchor, bottom: nil, right: view.rightAnchor, paddingTop: 17, paddingLeft: 0, paddingBottom: 0, paddingRight: 0, width: self.view.frame.width, height: 330)
currentEventImage.heightAnchor.constraint(equalToConstant: 330).isActive = true
currentEventImage.topAnchor.constraint(equalTo: blurryBackGround.topAnchor, constant: 5).isActive = true
currentEventImage.center = blurryBackGround.center
blurryBackGround.addSubview(currentEventImage)
Any idea how I would do that?
currentEventImage.center = blurryBackGround.convert(blurryBackGround.center, from: blurryBackGround.superview)
Tried this and it didn't work