1

I have a custom UIRefreshControl "pull to refresh" and for some reason, when I start to scroll, the view appears above all other views, instead of gradually showing itself as the scroll gets dragged down.. this is what I mean:

enter image description here

Now I've attempted to patch this up by making the background and tint colors clear in the viewDidLoad:

    var refreshControl: UIRefreshControl!

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        refreshControl = UIRefreshControl()
        refreshControl.backgroundColor = UIColor.clearColor()
        refreshControl.tintColor = UIColor.clearColor()
        collectionView?.addSubview(refreshControl)

    }

While this does fix the issue of the refresh just being plastered over everything, regardless of its transparency, the refreshControl is still on top of my view hierarchy, you can see when I release the scroll, the letters are still hanging over the view.. And while it does hide the view, when you begin to drag the scroll, it glitches really fast showing the view again:

enter image description here

Now I've even tried calling the sendSubviewToBack and insertSubview:aboveSubview: methods but they don't do anything.. Keep in mind this is a collectionViewController and not a UIViewController with a collectionView on top, so I guess there isn't a view behind the top view which i can send something to the back.. but is there any logic i can implement that will adjust the views bounds when the scrolling begins?

Mayank Patel
  • 3,868
  • 10
  • 36
  • 59
John Jackson
  • 900
  • 2
  • 12
  • 28

1 Answers1

1

Try this:

refreshControl.layer.zPosition = -1

Also, be careful about using UIRefreshControl without attaching it to an actual UITableViewController. You may see odd artifacts like stuttering (even attaching it to just a UITableView will cause errors). See:

UIRefreshControl without UITableViewController

Community
  • 1
  • 1
bobics
  • 2,301
  • 2
  • 23
  • 25
  • when I add it as a subView to my background, it just disappears, i mean the motions of the control are still there but, its not visible – John Jackson Sep 10 '15 at 20:59
  • i can cope with setting the RefreshControl's backgroundColor and tintColor to clear in the viewDidLoad to disguise itself properly, however what can I do about the sudden split second glitch where it negates this code and shows itself when the scroll dragging begins? – John Jackson Sep 10 '15 at 21:10
  • what can I do to prevent that? – John Jackson Sep 10 '15 at 21:11
  • @ItzhakIra do you have sample code, or a video / gif of the problem? – bobics Sep 11 '15 at 01:21
  • I think it's best if you add it to your original question, or link to it here (e.g. a public URL using dropbox). – bobics Sep 11 '15 at 07:43
  • the zPosition basically does the same as adding it to my backgroundView, it makes it disappear – John Jackson Sep 11 '15 at 09:47
  • Please provide a sample project and share in GitHub. – bobics Sep 11 '15 at 09:53
  • heres a link to a video showing the small glitch in the beginning of the scroll dragging https://www.dropbox.com/s/eryzqh0r1l27uv9/GLITCH.mov?dl=0 – John Jackson Sep 11 '15 at 10:02
  • as you can see, the code I added to make it clear when the view loads works, however for a small split second when the dragging begins, it shows itself – John Jackson Sep 11 '15 at 10:04