菜鸟教程小白 发表于 2022-12-11 19:37:17

ios - 淡出 UIRefreshControl 或将其从透明 ScrollView 中隐藏


                                            <p><p>我想以比平常更快的速度从透明 ScrollView 中隐藏我的 <code>UIRefreshControl</code> 并快速淡出,这样它就不会与文本重叠。任何类似的解决方案将不胜感激!</p>

<pre><code>let refreshControl = UIRefreshControl()

refreshControl.tintColor = UIColor.white
let color =
refreshControl.attributedTitle = NSAttributedString(string: &#34;Pull to refresh&#34;, 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()
}
</code></pre>

<p> <a href="/image/4Nmck.gif" rel="noreferrer noopener nofollow">+ Example</a> </p>

<p>你们有什么想法吗?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>你可以试试这个</p>

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

}
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 淡出 UIRefreshControl 或将其从透明 ScrollView 中隐藏,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/48308943/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/48308943/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 淡出 UIRefreshControl 或将其从透明 ScrollView 中隐藏