Skip to content

Commit

Permalink
barButton.addTarget(self, action: (position == .NavigationBarButtonA…
Browse files Browse the repository at this point in the history
…sLeft) ? #selector(UIViewController.leftBarButtonAction(_:)) : #selector(UIViewController.rightBarButtonAction(_:)), forControlEvents: .TouchUpInside)
  • Loading branch information
easyui committed Jul 25, 2016
1 parent 6f4bf40 commit 1e52b7e
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ extension UIViewController{
let barButton = UIButton(type: .Custom)
barButton.frame = CGRectMake(0, 0, 45, 40)
barButton.backgroundColor = UIColor.clearColor()
barButton.addTarget(self, action: Selector(position.rawValue), forControlEvents: .TouchUpInside)
// return self.scheduledTimerWithTimeInterval(timeInterval, target: self, selector: #selector(NSTimer.executeBlockWithTimer(_:)), userInfo: unsafeBitCast(block, AnyObject.self), repeats: repeats)

// barButton.addTarget(self, action: Selector(position.rawValue), forControlEvents: .TouchUpInside)
barButton.addTarget(self, action: (position == .NavigationBarButtonAsLeft) ? #selector(UIViewController.leftBarButtonAction(_:)) : #selector(UIViewController.rightBarButtonAction(_:)), forControlEvents: .TouchUpInside)
barButton.imageView?.contentMode = .ScaleAspectFit
if let image = normalImage{
barButton.setImage(image, forState: .Normal)
Expand Down Expand Up @@ -109,7 +112,7 @@ extension UIViewController{

}

@objc func leftBarButtonAction(sender: UIButton?)
@objc private func leftBarButtonAction(sender: UIButton?)
{
let switchEffect = objc_getAssociatedObject(self, &AssociatedKeys.SwitchEffectKey) as? Bool
if let _ = switchEffect {
Expand All @@ -126,7 +129,7 @@ extension UIViewController{
block(barButton: sender)
}

@objc func rightBarButtonAction(sender: UIButton?)
@objc private func rightBarButtonAction(sender: UIButton?)
{
let switchEffect = objc_getAssociatedObject(self, &AssociatedKeys.SwitchEffectKey) as? Bool
if let _ = switchEffect {
Expand Down

0 comments on commit 1e52b7e

Please sign in to comment.