Skip to content

Commit

Permalink
added text binding to BindableButton
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharyclaysmith committed Mar 26, 2015
1 parent b435d3c commit a71cc10
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions AwfulBindingUI/BindableButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,22 @@ public class BindableButton:UIButton{
}
}

private var _textBinding:BindableValue<String>?

public var textBinding:BindableValue<String>?{
get{
return _textBinding
}

set(newValue){
_textBinding?.removeListener(self)

_textBinding = newValue

_textBinding?.addListener(self, listener:textBindingChanged, alertNow: true)
}
}

deinit{
_enabledBinding?.removeListener(self)
_hiddenBinding?.removeListener(self)
Expand All @@ -36,6 +52,10 @@ public class BindableButton:UIButton{
self.enabled = newValue
}

private func textBindingChanged(newValue:String){
self.setTitle(newValue, forState: UIControlState.Normal)
}

private var _hiddenBinding:BindableValue<Bool>?

public var hiddenBinding:BindableValue<Bool>?{
Expand Down

0 comments on commit a71cc10

Please sign in to comment.