gpt4 book ai didi

ios - 如何重新定位 UIRefreshControl

转载 作者:行者123 更新时间:2023-11-30 12:05:48 31 4
gpt4 key购买 nike

我已以编程方式将 UIRefreshControl 作为 subview 添加到我的 UICollectionView 中。

lazy var refreshControl: UIRefreshControl = {
let refreshControl = UIRefreshControl()
refreshControl.addTarget(self, action: #selector(MyPhotospotsViewController.handleRefresh(_:)), for: UIControlEvents.valueChanged)
refreshControl.tintColor = UIColor.lightGray

return refreshControl
}()

override func viewDidLoad() {
super.viewDidLoad()

collectionView.addSubview(refreshControl)
}

我想将其稍微向下移动,但到目前为止我所做的一切都不起作用。我尝试了以下方法。

    refreshControl.frame = CGRect(x: refreshControl.frame.origin.x,
y: refreshControl.frame.origin.y - 50,
width: refreshControl.frame.size.width,
height: refreshControl.frame.size.height)

我也查过谷歌,但所有答案都在 Objective C 中。

我正在考虑以编程方式添加约束,但这感觉不正确。

最佳答案

您应该对其使用自动布局约束或在 -viewDidLayoutSubviews 中更新其框架。

关于ios - 如何重新定位 UIRefreshControl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46693804/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com