UIVisualEffectView面膜不工作在iPhone上7加模拟器

问题描述:

我想圆一个UIVisualEffectView像这样的两个上角:UIVisualEffectView面膜不工作在iPhone上7加模拟器

if let tabBarHeight = self.tabBarController?.tabBar.frame.height { 
     mainViewHeight = self.view.frame.height - tabBarHeight 
    } 

    let oneAndHalfMainViewHeight = mainViewHeight * 1.5 
    midStateHeight = mainViewHeight/2 - midStateConstant 
    let blur = UIBlurEffect(style: .dark) 
    slideView = UIVisualEffectView(effect: blur) 
    slideView.translatesAutoresizingMaskIntoConstraints = false 
    slideView.contentView.backgroundColor = Tools.colorPicker(2, alpha: 1) 
    self.view.addSubview(slideView) 

    let slideViewHorizontalConstraints = NSLayoutConstraint.constraints(withVisualFormat: "H:|[slideView(\(UIScreen.main.bounds.width))]|", options: NSLayoutFormatOptions(), metrics: nil, views: ["slideView" : slideView]) 
    slideViewHeightConstraint = NSLayoutConstraint(item: slideView, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: oneAndHalfMainViewHeight) 
    slideViewTopConstraint = NSLayoutConstraint(item: self.view, attribute: .bottom, relatedBy: .equal, toItem: slideView, attribute: .top, multiplier: 1, constant: alwaysVisibleHeight) 
    self.view.addConstraints(slideViewHorizontalConstraints) 
    guard let slideViewHeightConstraint = slideViewHeightConstraint, let slideViewTopConstraint = slideViewTopConstraint else { 
     return 
    } 
    self.view.addConstraint(slideViewHeightConstraint) 
    self.view.addConstraint(slideViewTopConstraint) 

    mainViewHeight = self.view.frame.height 
    midStateHeight = mainViewHeight/2 - midStateConstant 
    slideViewHeightConstraint.constant = oneAndHalfMainViewHeight 

    let maskLayer = CAShapeLayer() 
    let roundedRect = CGRect(x: 0, y: 0, width: view.bounds.width, height: oneAndHalfMainViewHeight) 
    maskLayer.frame = roundedRect 
    maskLayer.path = UIBezierPath(roundedRect: roundedRect, byRoundingCorners: [.topLeft, .topRight], cornerRadii: CGSize(width: 10, height: 10)).cgPath 

    let frame = CGRect(x: 0, y: 0, width: view.bounds.width, height: oneAndHalfMainViewHeight) 
    let maskView = UIView(frame: frame) 

    maskView.layer.addSublayer(maskLayer) 
    slideView.mask = maskView 

当我尝试在我的iPhone 7它能正常工作,但是, iPhone 7 Plus的模拟器没有显示视觉效果,我没有真正的iPhone 7 Plus来试用它。模拟器显示了iPhone 5s,SE,6和7的效果。所以我想知道如果我的代码给出了巨大的尺寸,或者是模拟器上的渲染问题,是否会出现问题。我使用的是2016年的15" 的MacBook Pro,7个加勉强适合在100%的画面谢谢

注:!这是发生在Xcode中的最新RELASE和Xcode的beta 4版本

更新:我已经能够尝试真正的iPhone 6S Plus和工作正常所以肯定一个模拟器图形问题

我已经能够尝试真正的iPhone 6S Plus和工作如预期的那样,绝对是模拟器的图形问题。