我提前道歉,因为这感觉很简单,但我一直试图弄清楚这几天,经过大量的搜索后无法弄明白。
当我检查图像的高度时,我用编程方式创建了约束,其大小与它的渲染大小不匹配。
// Earth Image Setup
view.addSubview(earthImageView)
earthImageView.bottomAnchor.constraint(equalTo: loginTextViewTitle.topAnchor, constant: -standardSpacer).isActive = true
earthImageView.widthAnchor.constraint(equalToConstant: 500).isActive = true
earthImageView.heightAnchor.constraint(equalToConstant: 500).isActive = true
earthImageView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
// Value of earthImageViewHeight is 276. Why isn't it 500?
let earthImageViewHeight = earthImageView.frame.size.height
我看到276来自原始@ 1x图像的像素高度。但是,如何获得实际渲染高度?
我认为它可能与points vs pixels有关,但似乎也不是这样。