How can I vertical-center a UIImageView in super view with the snapkit? I tried like this:
imageview.snp.makeConstraints { (make) in
make.centerY.equalTo(view.center.y);
}
but seems not well.How can I use the snapkit
How can I vertical-center a UIImageView in super view with the snapkit? I tried like this:
imageview.snp.makeConstraints { (make) in
make.centerY.equalTo(view.center.y);
}
but seems not well.How can I use the snapkit
Try following code
Imageview.snp.makeConstraints { (make) in
make.left.equalTo(view.snp.left).offset(50)
make.centerY.equalTo(self.view)
make.width.height.equalTo(100)
}
It's not enough to give the imageView a centerY only , you need to give it also width,height and x constraint , so try this
imageview.snp.makeConstraints { (make) in
make.left.equalTo(view.snp.left).offset(50)
make.centerY.equalTo(self.view)
make.width.height.equalTo(100)
}
If you want to set imageView in center of its superview with size of 100x100 then try below code;
imageview.snp.makeConstraints { (make) in
make.centerY.centerX.equalToSuperview()
make.height.width.equalTo(100)
}
If you want to set imageView in vertial-center and with 50px offset from leading edge of its superview with size of 100x100 then try below code;
imgView.snp.makeConstraints { (make) in
make.centerY.equalToSuperview()
make.leading.equalToSuperview().offset(50)
make.height.width.equalTo(100)
}