gpt4 book ai didi

ios - 将 UIRefreshControl 替换为 UIImageView

转载 作者:行者123 更新时间:2023-11-28 06:13:56 25 4
gpt4 key购买 nike

我的 UITableView 中有一个 UIRefreshControl。我想用我自己的替换系统的刷新图标。我试过像这样向 refreshControl 添加一个 subview ......

    let refreshImage = UIImageView()
refreshImage.image = UIImage(named: "RefreshIcon")
refreshControl.insertSubview(refreshImage, at: 0)
tableview.addSubview(refreshControl)

但这并没有奏效。有人有什么想法吗?非常感谢!

最佳答案

请试试这段代码:

 let refreshImage = UIImageView()
refreshImage.image = UIImage(named: "RefreshIcon")
refreshControl.backgroundColor = UIColor.clear
refreshControl.tintColor = UIColor.clear
refreshControl.addSubview(refreshImage)
tableview.addSubview(refreshControl)

然后将它居中到顶部,你可以使用这个:

    refreshImage.frame = refreshControl.bounds.offsetBy(dx: self.view.frame.size.width / 2 - 20 // half the width of the refreshImage, dy: 10)
refreshImage.frame.size.width = 40 // Whatever width you want
refreshImage.frame.size.height = 40 // Whatever height you want

关于ios - 将 UIRefreshControl 替换为 UIImageView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45673359/

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