我使用此代码在我的表视图上以编程方式刷新
extension UIRefreshControl {
func beginRefreshingManually() {
if let scrollView = superview as? UIScrollView {
scrollView.setContentOffset(CGPoint(x: 0, y: scrollView.contentOffset.y - frame.height), animated: true)
}
beginRefreshing()
sendActions(for: .valueChanged)
}
}
如果它工作正常,navigationController?.navigationBar.prefersLargeTitles = false
但如果它是 true 则 UIRefreshControl 不可见,请参阅下面的输出
这是结果,如果navigationController?.navigationBar.prefersLargeTitles = false
如您所见,加载视图后,它会自动旋转UIRefreshControl
,因为我调用了tableView.refreshControl?.beginRefreshingManually()
onviewDidAppear
这就是结果,如果navigationController?.navigationBar.prefersLargeTitles = true
如您所见,它加载了调用的函数,refreshControl.addTarget(self, action: #selector(refresh), for: .valueChanged)
但旋转动画不可见。
这是我设置导航栏大标题的代码
private func setupNaigationBar() {
navigationController?.navigationItem.largeTitleDisplayMode = .always
let style = NSMutableParagraphStyle()
style.firstLineHeadIndent = 10 // This is added to the default margin
navigationController?.navigationBar.prefersLargeTitles = true
navigationController?.navigationBar.largeTitleTextAttributes = [NSAttributedString.Key.font : UIFont(name: "Avenir-Heavy", size: 25)!, .foregroundColor: Keys.primaryColor, NSAttributedString.Key.paragraphStyle : style]
navigationController?.navigationBar.backgroundColor = .clear
view.layoutIfNeeded()
}
我的预期结果是看到UIRefreshControl
即使以navigationController?.navigationBar.prefersLargeTitles = true
编程方式(甚至没有用户滚动)