无法看到UIView的UIView子视图

我看不到添加到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是我在运行时无法在应用程序上看到的内容。即使它存在并且我已经将其放在最前面)

无法看到UIView的UIView子视图

lr1030 回答:无法看到UIView的UIView子视图

您在班级顶部初始化 select id,group1,group2,group3,Turnover,Cost,Turnover - Cost as Profit from ( select a.ID,c.Group1,a.group2,b.group3,sum( a.Qty * a.Price * (100 - a.discount) / 100 * a.Rate) ) as Turnover,sum( a.Qty * a.Cost ) as Cost,sum( a.Qty * a.Price * (100 - a.discount) / 100 * a.Rate) ) - sum( a.Qty * a.Cost ) from a INNER JOIN b ON a.id=b.id INNER JOIN c ON a.id2=c.id group by a.ID,b.group3 ) t

magnifyingView

但是您要在var magnifyingView: UIView = { let view = UIView() view.alpha = 1.0 view.backgroundColor = UIColor.yellow return view }() 中添加另一个magnifyingView = UIView()作为子视图。

本文链接:https://www.f2er.com/3166111.html

大家都在问