jamesmontemagno / Xamarin.Forms-PullToRefreshLayout

Pull To Refresh a ScrollView or ListView in Xamarin.Forms
218 stars 49 forks source link

iOS: UIRefreshControl always black on first refresh #54

Closed TinaGen closed 4 years ago

TinaGen commented 6 years ago

It seems the Refresh indicator always defaults to black on the first refresh, only on iOS.

I've set the UIRefreshControl.Appearance.TintColor in the AppDelegate and in the OnElementChanged of my ListViewRender.

Every subsequent refresh, the color is correct.

Exact same issue described here: https://bugzilla.xamarin.com/show_bug.cgi?id=34966

Miiite commented 5 years ago

The associated bugzilla has been closed / resolved, and I can't reproduce it on my side. I think we can close this one.

taublast commented 5 years ago

@TinaGen hi you can fork and fix the renderer youself (fixed for the case with a tableview, scrollview, for others didn't need yet, the issue is described here https://stackoverflow.com/questions/19026351/ios-7-uirefreshcontrol-tintcolor-not-working-for-beginrefreshing):

 bool TryInsertRefresh(UIView view, int index = 0)
        {
            this.refreshControlParent = view;

            if (view is UITableView)
            {
                var uiTableView = view as UITableView;
                uiTableView = view as UITableView;
                view.InsertSubview(refreshControl, index);

                #region bug fixed
                //fixed bug initial tint color is default
                if (uiTableView.ContentOffset.Y == 0)
                {
                    uiTableView.ContentOffset = new CGPoint(0, -refreshControl.Frame.Size.Height);
                }
                #endregion 

                return true;
            }
...

for scrollview:

            if (view is UIScrollView)
            {
                var uiScrollView = view as UIScrollView;
                view.InsertSubview(refreshControl, index);
                uiScrollView.AlwaysBounceVertical = true;

                #region bug fixed
                //fixed bug initial tint color is default
                if (uiScrollView.ContentOffset.Y == 0)
                {
                    uiScrollView.ContentOffset = (new CGPoint(0, -refreshControl.Frame.Size.Height*2.0));
                }
                #endregion 

                return true;

and set scroll to 0 after refreshed: https://github.com/jamesmontemagno/Xamarin.Forms-PullToRefreshLayout/issues/39#issuecomment-511419012

Bogenbai commented 5 years ago

I have the same issue.