7

2014 WWDC'sinin 214 oturumundaki gibi bir popover yapmaya çalışıyorum.iOS 8: Compact Mode'da Modal Popover'a Blur Etkisi ile UIVisualEffectView Uygulaması

enter image description here popover görünümü onun Superview dolduran bir metin görünümü içeren, aşağıdaki ile:

yüzden gibi bir "Mevcut As Popover" segue ile bağlı iki görünüm sahip IB kullanarak app inşa etmeye başlamıştı kısıtlamalar: aşağıdaki kodu modal popover desteklemek amacıyla enter image description here

:

func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle { 
    return .OverFullScreen 
} 

func presentationController(controller: UIPresentationController, viewControllerForAdaptivePresentationStyle style: UIModalPresentationStyle) -> UIViewController? { 

    let navigationController = UINavigationController(rootViewController: controller.presentedViewController) 
    controller.presentedViewController.navigationItem.setRightBarButtonItem(UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Done, target: self, action: "done"), animated: true) 

    return navigationController 
} 

Bu bana şu yeniden verdi sult: enter image description here

Sonra UIVisualEffectView'i bulanıklık efekti ile eklemeyi denedim. İlk başta, sunulan denetleyici görünümüne bir alt görünüm ekledim ve Görünüm Hiyerarşisini kontrol ettikten sonra etki görünümümün aslında metin görünümümün üstünde olduğunu fark ettim, ancak metin görünümüm doğru bir şekilde yerleştirildi. Böyle gibi bir yöntem: atIndex: Ben insertSubview çalıştı

func presentationController(controller: UIPresentationController, viewControllerForAdaptivePresentationStyle style: UIModalPresentationStyle) -> UIViewController? { 

    let effectView = UIVisualEffectView(effect: UIBlurEffect(style: .Light)) as UIVisualEffectView 
    effectView.setTranslatesAutoresizingMaskIntoConstraints(false) 
    controller.presentedViewController.view.insertSubview(effectView, atIndex: 0) 

    let viewList : [String : UIView] = ["effectView" : effectView] 

    let navigationController = UINavigationController(rootViewController: controller.presentedViewController) 
    controller.presentedViewController.navigationItem.setRightBarButtonItem(UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Done, target: self, action: "done"), animated: true) 


    controller.presentedViewController.view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[effectView]|", options: nil, metrics: nil, views: viewList)) 

    controller.presentedViewController.view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|-[effectView]|", options: nil, metrics: nil, views: viewList)) 

    return navigationController 
} 

Ama hala IB tanımlanan metin görünümü sunmak alamıyorum: Görebildiğim Görüntüle Hiyerarşi sayesinde enter image description here

benim metin UIVisualEffectView dizinine 0 eklediğimde, gezinme çubuğunun altında gezinmek her zaman geziniyor.

Gezinme çubuğunun altında kaybolmadan/hareket etmeden, bulanıklaştırma efektini metnimin altında nasıl programlayabildiğim konusunda herhangi bir fikrim var mı?

Cheers

cevap

0

Bu işlev size yardımcı oluyor mu?

view.insertSubview(view: effectView, belowSubview: label)