2017-03-16 74 views
0

我想圓一個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和工作正常所以肯定一個模擬器圖形問題

回答

0

我已經能夠嘗試真正的iPhone 6S Plus和工作如預期的那樣,絕對是模擬器的圖形問題。

相關問題