Ios 快速页面视图控制器梯度
它基于苹果的pageviewcontroller。 有两个viewcontroller。根视图,页视图控制器。 我需要在pageview为flip(?)page时,更改rootview子层的渐变颜色。 这是我的ChangeGradeClient函数Ios 快速页面视图控制器梯度,ios,swift,Ios,Swift,它基于苹果的pageviewcontroller。 有两个viewcontroller。根视图,页视图控制器。 我需要在pageview为flip(?)page时,更改rootview子层的渐变颜色。 这是我的ChangeGradeClient函数 func changeGradient(){ repeat { randomIndex = Int(arc4random_uniform(UInt32(StartColorcarr.count))) } while
func changeGradient(){
repeat {
randomIndex = Int(arc4random_uniform(UInt32(StartColorcarr.count)))
} while randomIndex == lastIndex
lastIndex = randomIndex
self.gradient.colors = [
UIColor(netHex:(self.StartColorcarr[self.randomIndex])).cgColor,
UIColor(netHex:(self.EndColorcarr[self.randomIndex])).cgColor
]
}
这是模型控制器
func indexOfViewController(_ viewController: DataViewController) -> Int {
// Return the index of the given data view controller.
// For simplicity, this implementation uses a static array of model objects and the view controller stores the model object; you can therefore use the model object to identify the index.
return pageData.index(of: viewController.dataObject) ?? NSNotFound
}
我认为这是当页面被滚动时的功能。
我的问题。
我无法在ModelController或DataviewController上调用Rootviewcontroller中的函数
gradient.frame = view.bounds
gradient.startPoint = CGPoint(x: 0.0, y: 0.0)
gradient.endPoint = CGPoint(x: 1.0, y: 1.0)
gradient.colors = [
UIColor(netHex:(0x2a5cdc)).cgColor,
UIColor(netHex:(0x13e999)).cgColor
]
gradient.frame = self.view.bounds
self.view.layer.insertSublayer(gradient, at: 0)
这是RootviewController的子层,我是如何制作的
所以请帮助我,拯救我
愿上帝帮助我们所有人