我看不到添加到UIView的UIView子视图。我可以在视图层次结构中清楚地看到它,但是当应用程序运行时我只是看不到它。
代码:
var magnifyingView: UIView = {
let view = UIView()
view.alpha = 1.0
view.backgroundColor = UIColor.yellow
return view
}()
guard let cgImage = capturedImage else{return}
let image = UIImage.init(cgImage: cgImage,scale: 1.0,orientation: UIImage.Orientation.right)
imageView.image = image
self.addSubview(imageView)
bottomSection.addSubview(homeButton)
bottomSection.addSubview(retakeButton)
bottomSection.addSubview(continueButton)
self.addSubview(bottomSection)
showMagifyingView()
self.bringSubviewToFront(magnifyingView)
private func showMagifyingView(){
magnifyingView = UIView()
magnifyingView.frame = CGRect.init(x: 30,y: 30,width: 200,height: 200)
self.addSubview(magnifyingView)
magnifyingView.translatesAutoresizingMaskintoConstraints = false
magnifyingView.widthAnchor.constraint(equalTo: self.widthAnchor,multiplier: 0.3).isactive = true
magnifyingView.heightAnchor.constraint(equalTo: self.widthAnchor,multiplier: 0.3).isactive = true
magnifyingView.topAnchor.constraint(equalTo: self.topAnchor,constant: 30).isactive = true
magnifyingView.trailingAnchor.constraint(equalTo: self.trailingAnchor,constant: -30).isactive = true
}
查看层次结构(蓝色突出显示的矩形UIview是我在运行时无法在应用程序上看到的内容。即使它存在并且我已经将其放在最前面)