1
我有一個導航欄和一個rightBarButtonItem。我如何將一個UIActivityIndicatorView放在NavigationBar按鈕上(rightBarButtonItem/leftBarButtonItem)
當有人點擊這個按鈕時,我想把一個UIActivityIndicatorView放在它的頂部,然後我可以在回調完成後加載無論它是否加載。
我將如何實現這一目標?
目前的情況是,我有:
var navBar: UINavigationBar = UINavigationBar(frame: CGRectMake(0, 0, self.view.bounds.width, 64))
navBar.barTintColor = UIColor.whiteColor()
navBar.translucent = false
navBar.titleTextAttributes = [ NSForegroundColorAttributeName : UIColor.darkGrayColor() ]
self.view.addSubview(navBar)
var buttonRight = UIBarButtonItem(image: UIImage(named: "Search"), style: .Plain, target: self, action: Selector("goSearch"))
buttonRight.tintColor = UIColor(hexString: "056A85")
var navigationItem = UINavigationItem()
navigationItem.rightBarButtonItem = buttonRight
navigationItem.title = title
navBar.pushNavigationItem(navigationItem, animated: false)