Swift UITableView 滑动到顶部代码示例
要使 UITableView 滑动到顶部,可以使用以下代码:
let indexPath = IndexPath(row: 0, section: 0)
tableView.scrollToRow(at: indexPath, at: .top, animated: true)
上述代码将滑动到第一个 section 的第一行,即顶部位置。'animated' 参数可以设置为 'true' 以启用动画效果,或设置为 'false' 以直接跳转到顶部位置。
原文地址: https://www.cveoy.top/t/topic/paDP 著作权归作者所有。请勿转载和采集!