淡出UIRefreshControl或将其隐藏在透明滚动视图中

时间:2018-01-17 19:52:22

标签: ios swift refresh uicolor uirefreshcontrol

我希望从我的透明滚动视图中隐藏我的UIRefreshControl,使其快速淡出,因此它不会与文本重叠。任何类似的解决方案将不胜感激!

let refreshControl = UIRefreshControl()

refreshControl.tintColor = UIColor.white
let color = [NSAttributedStringKey.foregroundColor: UIColor.white]
refreshControl.attributedTitle = NSAttributedString(string: "Pull to refresh", attributes: color)
refreshControl.addTarget(self, action: #selector(refreshData), for: .valueChanged)
scrollView.refreshControl = refreshControl

@objc func refreshData(refreshControl: UIRefreshControl) {

    updateBitcoinValueLabel()
    updateBitcoinCashValueLabel()
    updateEthereumValueLabel()
    updateLitecoinValueLabel()
    updateRippleValueLabel()
    updateWalletValueLabel()

    refreshControl.endRefreshing()
}

+ Example

你们有什么想法吗?

2 个答案:

答案 0 :(得分:0)

你可以试试这个

override func scrollViewWillEndDragging(_ scrollView: UIScrollView, 
                       withVelocity velocity: CGPoint, 
                targetContentOffset: UnsafeMutablePointer<CGPoint>)
 {
     self.refreshControl.isHidden = true

 }

答案 1 :(得分:0)

我已解决此问题,替换为:

scrollView.refreshControl = refreshControl

与此:

scrollView.addSubview(refreshControl)