3

I am using SVProgressHUD for loader. When i use setContainerView method the loader is not displaying in centre. Can any one help me out.

Used below code to show Loader

 + (void)showLoadingHUDForView:(UIView *)view {
    if (view != nil) {
        [SVProgressHUD setRingThickness:3.0];
        [SVProgressHUD setContainerView:requiredView];
        [SVProgressHUD setDefaultStyle:SVProgressHUDStyleDark];
        [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeClear];
        [SVProgressHUD show];
    }
}
Anjaneyulu Battula
  • 1,910
  • 16
  • 33
  • R u calling this function in `viewdidload` method – Maddy May 15 '17 at 10:47
  • yes @Maddy some places i am calling this from viewWillAppear, viewdidload. From these methods i am calling one more method that contains api request and response. When ever i call request then calling show HUD method. – Anjaneyulu Battula May 15 '17 at 12:32

1 Answers1

0

The solution is to set the progressHUD's offset from center, like so:

let containerOrigin = requiredView.origin
SVProgressHUD.setOffsetFromCenter(UIOffset(horizontal: -containerOrigin.x, vertical: -containerOrigin.y))

If your requiredView is contained in another view, you will have to take in consideration all the parent views in the hierarchy, because progressHUD offset seems to be relative to the app's window.

Calin Drule
  • 2,899
  • 1
  • 15
  • 12