mám UIRefreshControl
v mojom UITableView
, Chcem vymeniť ikonu obnovenia systému za vlastnú. Pokúsil som sa pridať iba nový náhľad do ovládacieho prvku obnovenia, ako je to ...
let refreshImage = UIImageView()
refreshImage.image = UIImage(named: "RefreshIcon")
refreshControl.insertSubview(refreshImage, at: 0)
tableview.addSubview(refreshControl)
Ale to nefungovalo. Má niekto nejaké nápady? Mnohokrat dakujem!
odpovede:
1 pre odpoveď č. 1Skúste tento kód:
let refreshImage = UIImageView()
refreshImage.image = UIImage(named: "RefreshIcon")
refreshControl.backgroundColor = UIColor.clear
refreshControl.tintColor = UIColor.clear
refreshControl.addSubview(refreshImage)
tableview.addSubview(refreshControl)
a potom ho vycentrovať na vrchol, môžete použiť toto:
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