How to place an ImageView in the center of a UIView?
Code:
let dailyUIView = UIView(frame: CGRect(x: 0, y: 420, width: view.frame.size.width, height: 40))
dailyUIView.layer.masksToBounds = true
dailyUIView.backgroundColor = UIColor(named: "dailyTest")
scrollView.addSubview(dailyUIView)
let weatherIconImageView = UIImageView(frame: CGRect(x: 70, y: 0, width: 60, height: 60))
weatherIconImageView.image = UIImage(named: "01d")
dailyUIView.addSubview(weatherIconImageView)
3
Answers
try this it will maybe help
Userful and Effective Extension for Adding Constraints in single line:
}
Usage: