0
我已經以編程方式將UIRefreshControl添加爲我的UICollectionView的子視圖。如何重新定位UIRefreshControl
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)
我也有對谷歌看看,但所有的答案都在客觀C.
我想的編程方式添加約束,但感覺不正確。
你在哪裏設置這個框架在你的代碼中,在哪個函數中? – 3stud1ant3
在ViewDidLoad()中。我簡化了上面的ViewDidLoad函數 –
試試這個代碼:'refreshControl.frame = refreshControl.frame.offsetBy(dx:0,dy:-50)' – 3stud1ant3