0
在我的其中一個遊戲中,我使用UICollectionView作爲級別選擇菜單。我最近以編程方式向它添加了一個UIPageControl。UIPageControl在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])
}
iOS上的一切都很好,但在tvOS上,PageController具有半透明背景,可以在屏幕上延伸。
我如何關閉這個功能?我試圖設置pageControl背景顏色,但似乎沒有工作。
[更改背景顏色的頁面控件]的可能重複去除tvOS背景(http://stackoverflow.com/questions/33235857/change -background色換頁控制) – Moshe