繁体   English   中英

自定义 UIRefreshControl 内容未逐渐显示

[英]Custom UIRefreshControl content not showing gradually

我创建了一个自定义视图并将其作为子视图添加到我的滚动视图的刷新控件中,如下所示:

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 完全出现时出现。

似乎解决方案很简单:

scrollView.refreshControl?.clipsToBounds = true

希望这对将来的人有所帮助!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM