[英]Center an icon image which is inside image which is inside stackview
大家好,我想将图像置于堆栈视图内的图像中心。
let stackview = UIStackView()
stackview.addArrangedSubview(imageview)
imageview.addSubview(anotherimageview)
我想要另一个图像视图居中,这是一个图标图像。
添加anotherImageView
作为imageView
的子视图后,以您想要的方式设置其约束。
所以,在这一行之后:
imageview.addSubview(anotherimageview)
添加以下内容:
anotherimageview.translatesAutoresizingMaskIntoConstraints = false
anotherimageview.centerXAnchor.constraint(equalTo: imageview.centerXAnchor).isActive = true
anotherimageview.centerYAnchor.constraint(equalTo: imageview.centerYAnchor).isActive = true
// And do the same for the width and height constraints.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.