【问题标题】:Custom UIRefreshControl content not showing gradually自定义 UIRefreshControl 内容未逐渐显示
【发布时间】: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


    【解决方案1】:

    似乎解决方案很简单:

    scrollView.refreshControl?.clipsToBounds = true
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-14
      • 2016-08-25
      • 1970-01-01
      • 2011-07-10
      • 1970-01-01
      • 1970-01-01
      • 2014-08-21
      • 1970-01-01
      相关资源
      最近更新 更多