내가 찾는 것을 구현하는 애니메이션을 기울기 보기입니다.
모든 단계에 도움을까요? 현재 저는 모든 것을 준비하고 정적 배경에 첨부 세포를 보여줍니다에 선택하고 숨기지 않을 때 선택합니다. 어려운 부분은 애니메이션과 함께 일하는 내가 필요 몇 가지 있습니다.
내가 찾는 것을 구현하는 애니메이션을 기울기 보기입니다.
모든 단계에 도움을까요? 현재 저는 모든 것을 준비하고 정적 배경에 첨부 세포를 보여줍니다에 선택하고 숨기지 않을 때 선택합니다. 어려운 부분은 애니메이션과 함께 일하는 내가 필요 몇 가지 있습니다.
귀하의 수 있는 이 방법을 시도하십시오 ->보기 컨트롤러
class VC2: UIViewController {
// MARK:- IBOutlets
@IBOutlet weak var tblSample: UITableView!
// MARK:- Private Variables
private var SelectedCell: Int?
// MARK:- View Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
initialConfig()
}
// MARK:- Initial Config
private func initialConfig() {
tblSample.delegate = self
tblSample.dataSource = self
}
}
//표 보기 위임
extension VC2: UITableViewDelegate {
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 50
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
SelectedCell = indexPath.row
tblSample.reloadData()
}
}
//표 DataSource
extension VC2: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 10
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell()
cell.textLabel?.text = "\(indexPath.row)"
cell.selectionStyle = .none
if SelectedCell == indexPath.row {
DispatchQueue.main.async {
UIView.animate(withDuration: 1,delay: 0.5, options: .curveEaseIn) {
cell.contentView.applyGradient(colours: [.white,.blue])
}
}
}
return cell
}
}
//확장을 위해 적용하고 제거하라
extension UIView {
@discardableResult
func applyGradient(colours: [UIColor]) -> CAGradientLayer {
return self.applyGradient(colours: colours, locations: nil)
}
@discardableResult
func applyGradient(colours: [UIColor], locations: [NSNumber]?) -> CAGradientLayer {
let gradient: CAGradientLayer = CAGradientLayer()
gradient.frame = self.bounds
gradient.colors = colours.map { $0.cgColor }
gradient.locations = locations
self.layer.insertSublayer(gradient, at: 0)
return gradient
}
func removeGradient() {
for lay in self.layer.sublayers ?? [] {
if lay is CAGradientLayer {
lay.removeFromSuperlayer()
}
}
}
}