0

My Custom Activity indicator is not overlapping Navigation controller.

Below is my code

     func showActivityIndicator(uiView: UIView) {
        container.frame = uiView.frame
        container.center = uiView.center
        container.backgroundColor = UIColorFromHex(0xffffff, alpha: 0.1)

         var loadingView: UIView = UIView()
         loadingView.frame = CGRectMake(0, 0, self.view.frame.width, self.view.frame.height)
        loadingView.center = uiView.center
        loadingView.backgroundColor = UIColorFromHex(0x444444, alpha: 0.5)
        loadingView.clipsToBounds = true
        loadingView.layer.cornerRadius = 10

        var imageData = NSData(contentsOfURL: NSBundle.mainBundle()
        .URLForResource("synch-loader", withExtension: "gif")!)
        let try = UIImage.animatedImageWithData(imageData!)
        var imageView = UIImageView(image: try)

        imageView.center = uiView.center
        imageView.frame = CGRect(x: uiView.frame.width/4, y: uiView.frame.height/2, width: 500, height: 15)

        loadingView.addSubview(imageView)
        container.addSubview(loadingView)
        uiView.addSubview(container)
        actInd.startAnimating()

    }

    func navigationHandling()
     {
              if self.navigationController != nil {
             self.navigationController?.navigationBar.tintColor = utility.uicolorFromHex(0x70B420)
            self.navigationController?.navigationBar.barTintColor = utility.uicolorFromHex(0x70B420)
           self.navigationController?.navigationBarHidden = false
            self.navigationItem.hidesBackButton = true

    }
         sortingBtn = UIBarButtonItem(image: sortingImg,  style: UIBarButtonItemStyle.Done, target: self, action: Selector("sortingPressed:"))

          menuBtn = UIBarButtonItem(image: menuImg,  style: UIBarButtonItemStyle.Plain, target: self, action : nil)
          sortingBtn.tintColor = UIColor.whiteColor()
          menuBtn.tintColor = UIColor.whiteColor()
          var buttons : NSArray = [menuBtn,sortingBtn]
          self.navigationItem.rightBarButtonItems = buttons as [AnyObject]
         self.navigationItem.setRightBarButtonItems([menuBtn,sortingBtn], animated: true)
          networkLabel.hidden = true

}

I just want to overlap the view on navigation controller so that it don't looks ugly.

I appreciate help!

2 Answers 2

1
let appDelegate = UIApplication.sharedApplication().delegate as? AppDelegate
let window = appDelegate?.window
window.addSubview("yourActivityIndicator")

Here add the activity indicator to the window, or pass the window in as the view.

let appDelegate = UIApplication.sharedApplication().delegate as? AppDelegate
let window = appDelegate?.window
showActivityIndicator(window)
Sign up to request clarification or add additional context in comments.

1 Comment

this code worked before , now for some reason i don t see activity indicator, when I set window.makeVisible I can see it, ...
0

The uiView you're passing as parameter to this method

func showActivityIndicator(uiView: UIView)

is your ViewController's view or your UINavigationController's view? Because if it's your UIViewController's view your custom loading will take it's size and origin, that is under your NavigationBar

2 Comments

yes i passing UIViewController's view...What should i do to include navigation controller in it?
Your navigationController is also n UIViewControllers, so it has an UIView called view, that will maintain a navigationBar and a container for child ViewControllers. So, you can just pass navigationController.view to this method and this loading will be all other views that are inside NavigationController

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.