2017-03-05 1 views
0

In einem meiner Spiele verwende ich eine UICollectionView als Ebene Auswahlmenü. Ich habe vor kurzem programmgesteuert ein UIPageControl hinzugefügt.UIPageControl hat Hintergrund auf tvOS

 /// Page control 
func setupPageControl() { 
    pageControl.hidesForSinglePage = true 
    pageControl.numberOfPages = DataSource.worlds 
    pageControl.translatesAutoresizingMaskIntoConstraints = false 
    pageControl.currentPageIndicatorTintColor = DataSource.pageControlColors[pageControl.currentPage] 
    pageControl.pageIndicatorTintColor = UIColor.white.withAlphaComponent(0.8) 
    pageControl.addTarget(self, action: #selector(didPressPageControl), for: .valueChanged) 
    view.addSubview(pageControl) 

    let leading = NSLayoutConstraint(item: pageControl, attribute: .leading, relatedBy: .equal, toItem: view, attribute: .leading, multiplier: 1, constant: 0) 
    let trailing = NSLayoutConstraint(item: pageControl, attribute: .trailing, relatedBy: .equal, toItem: view, attribute: .trailing, multiplier: 1, constant: 0) 

    let bottomConstant = Device.isPad ? view.frame.width/9 : view.frame.width/17 
    let bottom = NSLayoutConstraint(item: pageControl, attribute: .bottom, relatedBy: .equal, toItem: view, attribute: .bottom, multiplier: 1, constant: -bottomConstant) 
    view.addConstraints([leading, trailing, bottom]) 
} 

Alles ist auf iOS in Ordnung, aber auf tvOS hat der Pagecontroller einen durchscheinenden Hintergrund, die alle über den Bildschirm erstreckt.

enter image description here

Wie kann ich das abschalten? Ich habe versucht, die pageControl Hintergrundfarbe einzustellen, aber das scheint nicht zu funktionieren.

+0

Mögliche Duplikat [Hintergrundfarbe ändern für Seitensteuerung] entfernen (http://stackoverflow.com/questions/33235857/change -background-color-for-page-Kontrolle) – Moshe

Antwort

0

Wie üblich, nur wenn ich eine Frage posten finde ich die Antwort eine Minute später.

Sie den Hintergrund auf tvOS durch Aufruf dieser

#if os(tvOS) 
    for subview in pageControl.subviews { 
     let effectView = subview as? UIVisualEffectView 
     effectView?.removeFromSuperview() 
    } 
#endif 

Change background color for page control