将 UIRefreshControl 替换为 UIImageView
Replace UIRefreshControl with UIImageView
我的 UITableView
中有一个 UIRefreshControl
。我想用我自己的替换系统的刷新图标。我试过像这样向 refreshControl 添加一个子视图...
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
我的 UITableView
中有一个 UIRefreshControl
。我想用我自己的替换系统的刷新图标。我试过像这样向 refreshControl 添加一个子视图...
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