ios - Gradient with TableView -
i made gradient tableview , works normally, when scroll upwards, black space appears, how can fix it, i know because made transparent tableview. it possible , on objective-c
let gradient = cagradientlayer() var gradientset = [[cgcolor]]() var currentgradient: int = 0 override func viewdidappear(_ animated: bool) { super.viewdidappear(animated) gradientset.append([gradientone, gradienttwo]) gradientset.append([gradienttwo, gradientthree]) gradientset.append([gradientthree, gradientone]) gradient.frame = self.tableview.bounds gradient.colors = gradientset[currentgradient] gradient.startpoint = cgpoint(x:0, y:0) gradient.endpoint = cgpoint(x:1, y:1) gradient.drawsasynchronously = true tableview.layer.insertsublayer(gradient, at: 0) animategradient() } func animategradient() { if currentgradient < gradientset.count - 1 { currentgradient += 1 } else { currentgradient = 0 } let gradientchangeanimation = cabasicanimation(keypath: "colors") gradientchangeanimation.delegate = self gradientchangeanimation.duration = 5.0 gradientchangeanimation.tovalue = gradientset[currentgradient] gradientchangeanimation.fillmode = kcafillmodeforwards gradientchangeanimation.isremovedoncompletion = false gradient.add(gradientchangeanimation, forkey: "colorchange") } func animationdidstop(_ anim: caanimation, finished flag: bool) { if flag { gradient.colors = gradientset[currentgradient] animategradient() } }
i recommend applying gradient uiview sits behind tableview. viewcontrollers view, or new uiview. need make sure size uiview match table.
Comments
Post a Comment