【发布时间】:2022-06-28 04:14:55
【问题描述】:
我创建了一个自定义视图并将其作为子视图添加到我的滚动视图的刷新控件中,如下所示:
private func configureRefreshControl() {
scrollView.refreshControl = UIRefreshControl()
let refreshContents = BaseRefreshControl.loadFromNib()
refreshContents.frame = scrollView.refreshControl!.bounds
self.refreshControl = refreshContents
scrollView.refreshControl?.tintColor = .clear
scrollView.refreshControl?.backgroundColor = .blue
scrollView.refreshControl?.addSubview(refreshContents)
}
我的BaseRefreshControl 基本上是一个 .xib 文件,其中包含一个 UIView 和一个以该 UIView 为中心的 UILabel。
您可能知道,当您下拉滚动视图以刷新内容时,它会逐渐打开(很像慢速动画)。然而,我发现奇怪的是,每当我下拉刷新时,我的 UILabel 会在 UIView 的中心部分显示之前显示。
如果可以的话,我所拥有的是这样的:
---------------------------
-- --
-- --------------------- --
-- MyLabel --
-- --
上半部分是我的 UIRefreshControl,它已经逐渐开始显示了。 'MyLabel' 正在显示和重叠下面的视图控制器的元素。我希望标签仅在 UIRefreshControl 的那部分显示时出现,仅在 UIView 完全出现时出现。
【问题讨论】:
标签: ios swift scrollview uirefreshcontrol