我设置1
2
3
就像这样:
UIImageView
它变为325x325而不是140x140。怎么样?至少控制台应该打印它会破坏一些约束吗?
let imageSize: CGFloat = 140
let profileImage = RoundImageView()
profileImage.image = UIImage(named: "girl_0")
profileImage.clipsToBounds = true
profileImage.translatesAutoresizingMaskIntoConstraints = false
profileImage.contentMode = .scaleAspectFill
profileImage.layer.masksToBounds = true
profileImage.layer.borderColor = UIColor.GSBackground().cgColor
profileImage.layer.borderWidth = 4.0
addSubview(profileImage)
profileImage.topAnchor.constraint(equalTo: topAnchor, constant: 18).isActive = true
profileImage.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true
profileImage.heightAnchor.constraint(equalToConstant: imageSize).isActive = true
profileImage.widthAnchor.constraint(equalToConstant: imageSize).isActive = true
我尝试将两个轴的<...RoundImageView: 0x11903e470; baseClass = UIImageView; frame = (117.5 18; 325 325); clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x1d023a700>>
设置为1000,但不起作用。
我已经尝试在[{1}}中为profileImage.setContentHuggingPriority()
返回140x140,但没关系,它仍然是325x325(但是说intristicContentSize
。
我已尝试UIImageView
而不是140 (content size)
。
我只是感到困惑。
完整披露,这里是.scaleAspectFit
:
.scaleAspectFill