Class: MMDrawerMenuButtonView
- Inherits:
-
UIButton
- Object
- UIButton
- MMDrawerMenuButtonView
- Defined in:
- lib/liam/MMDrawerBarButtonView.rb
Instance Attribute Summary collapse
-
#menuButtonHighlightedColor ⇒ Object
Returns the value of attribute menuButtonHighlightedColor.
-
#menuButtonNormalColor ⇒ Object
Returns the value of attribute menuButtonNormalColor.
-
#shadowHighlightedColor ⇒ Object
Returns the value of attribute shadowHighlightedColor.
-
#shadowNormalColor ⇒ Object
Returns the value of attribute shadowNormalColor.
Instance Method Summary collapse
-
#drawRect(rect) ⇒ Object
def drawRect:(CGRect)rect{.
-
#highlighted=(highlighted) ⇒ Object
def setHighlighted:(BOOL)highlighted{.
-
#initWithFrame(frame) ⇒ Object
def initWithFrame:(CGRect)frame{.
-
#menuButtonColorForState(state) ⇒ Object
def menuButtonColorForState:(UIControlState)state{.
-
#selected=(selected) ⇒ Object
def setSelected:(BOOL)selected{.
-
#setMenuButtonColor(color, forState: state) ⇒ Object
def setMenuButtonColor:(UIColor *)color forState:(UIControlState)state{.
-
#setShadowColor(color, forState: state) ⇒ Object
def setShadowColor:(UIColor *)color forState:(UIControlState)state{.
-
#shadowColorForState(state) ⇒ Object
def shadowColorForState:(UIControlState)state{.
-
#touchesBegan(touches, withEvent: event) ⇒ Object
def touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{.
-
#touchesCancelled(touches, withEvent: event) ⇒ Object
def touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{.
-
#touchesEnded(touches, withEvent: event) ⇒ Object
def touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{.
Instance Attribute Details
#menuButtonHighlightedColor ⇒ Object
Returns the value of attribute menuButtonHighlightedColor.
4 5 6 |
# File 'lib/liam/MMDrawerBarButtonView.rb', line 4 def @menuButtonHighlightedColor end |
#menuButtonNormalColor ⇒ Object
Returns the value of attribute menuButtonNormalColor.
3 4 5 |
# File 'lib/liam/MMDrawerBarButtonView.rb', line 3 def @menuButtonNormalColor end |
#shadowHighlightedColor ⇒ Object
Returns the value of attribute shadowHighlightedColor.
6 7 8 |
# File 'lib/liam/MMDrawerBarButtonView.rb', line 6 def shadowHighlightedColor @shadowHighlightedColor end |
#shadowNormalColor ⇒ Object
Returns the value of attribute shadowNormalColor.
5 6 7 |
# File 'lib/liam/MMDrawerBarButtonView.rb', line 5 def shadowNormalColor @shadowNormalColor end |
Instance Method Details
#drawRect(rect) ⇒ Object
def drawRect:(CGRect)rect{
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/liam/MMDrawerBarButtonView.rb', line 73 def drawRect(rect) # General Declarations context = UIGraphicsGetCurrentContext() #CGContextRef # Sizes = CGRectGetWidth(self.bounds) * 0.80 = CGRectGetHeight(self.bounds) * 0.16 xOffset = CGRectGetWidth(self.bounds) * 0.10 yOffset = CGRectGetHeight(self.bounds) * 0.12 cornerRadius = 1.0 # Color Declarations = self.(self.state) shadowColor = self.shadowColorForState(self.state) # Shadow Declarations shadow = shadowColor shadowOffset = CGSizeMake(0.0, 1.0) shadowBlurRadius = 0 # Top Bun Drawing topBunPath = UIBezierPath.bezierPathWithRoundedRect(CGRectMake(xOffset, yOffset, , ), cornerRadius:cornerRadius) # UIBezierPath CGContextSaveGState(context) CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor) .setFill topBunPath.fill CGContextRestoreGState(context) # Meat Drawing meatPath = UIBezierPath.bezierPathWithRoundedRect(CGRectMake(xOffset, yOffset*2 + , , ), cornerRadius:cornerRadius) # UIBezierPath* CGContextSaveGState(context) CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor) .setFill meatPath.fill CGContextRestoreGState(context) # Bottom Bun Drawing bottomBunPath = UIBezierPath.bezierPathWithRoundedRect(CGRectMake(xOffset, yOffset*3 + *2, , ), cornerRadius:cornerRadius) # UIBezierPath* CGContextSaveGState(context) CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor) .setFill bottomBunPath.fill CGContextRestoreGState(context) end |
#highlighted=(highlighted) ⇒ Object
def setHighlighted:(BOOL)highlighted{
144 145 146 147 |
# File 'lib/liam/MMDrawerBarButtonView.rb', line 144 def highlighted=(highlighted) super self.setNeedsDisplay end |
#initWithFrame(frame) ⇒ Object
def initWithFrame:(CGRect)frame{
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/liam/MMDrawerBarButtonView.rb', line 9 def initWithFrame(frame) # self = super.initWithFrame(frame) if(super) self.setMenuButtonNormalColor(UIColor.whiteColor.colorWithAlphaComponent(0.9)) self.setMenuButtonHighlightedColor(UIColor.colorWithRed(139.0/255.0, green:135.0/255.0, blue:136.0/255.0, alpha:0.9)) self.setShadowNormalColor(UIColor.blackColor.colorWithAlphaComponent(0.5)) self.setShadowHighlightedColor(UIColor.blackColor.colorWithAlphaComponent(0.2)) end return self end |
#menuButtonColorForState(state) ⇒ Object
def menuButtonColorForState:(UIControlState)state{
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/liam/MMDrawerBarButtonView.rb', line 22 def (state) color = UIColor.greenColor # A default color just in case, get it, that was funny. case (state) when UIControlStateNormal color = self. when UIControlStateHighlighted color = self. end return color end |
#selected=(selected) ⇒ Object
def setSelected:(BOOL)selected{
138 139 140 141 |
# File 'lib/liam/MMDrawerBarButtonView.rb', line 138 def selected=(selected) super self.setNeedsDisplay end |
#setMenuButtonColor(color, forState: state) ⇒ Object
def setMenuButtonColor:(UIColor *)color forState:(UIControlState)state{
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/liam/MMDrawerBarButtonView.rb', line 36 def setMenuButtonColor(color, forState:state) case (state) when UIControlStateNormal self.setMenuButtonNormalColor(color) when UIControlStateHighlighted self.setMenuButtonHighlightedColor(color) end self.setNeedsDisplay end |
#setShadowColor(color, forState: state) ⇒ Object
def setShadowColor:(UIColor *)color forState:(UIControlState)state{
62 63 64 65 66 67 68 69 70 |
# File 'lib/liam/MMDrawerBarButtonView.rb', line 62 def setShadowColor(color, forState:state) case (state) when UIControlStateNormal self.setShadowNormalColor(color) when UIControlStateHighlighted self.setShadowHighlightedColor(color) end self.setNeedsDisplay end |
#shadowColorForState(state) ⇒ Object
def shadowColorForState:(UIControlState)state{
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/liam/MMDrawerBarButtonView.rb', line 48 def shadowColorForState(state) color = UIColor.redColor # A default color case (state) when UIControlStateNormal color = self.shadowNormalColor when UIControlStateHighlighted color = self.shadowHighlightedColor end return color end |
#touchesBegan(touches, withEvent: event) ⇒ Object
def touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
120 121 122 123 |
# File 'lib/liam/MMDrawerBarButtonView.rb', line 120 def touchesBegan(touches, withEvent:event) super self.setNeedsDisplay end |
#touchesCancelled(touches, withEvent: event) ⇒ Object
def touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{
132 133 134 135 |
# File 'lib/liam/MMDrawerBarButtonView.rb', line 132 def touchesCancelled(touches, withEvent:event) super self.setNeedsDisplay end |
#touchesEnded(touches, withEvent: event) ⇒ Object
def touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
126 127 128 129 |
# File 'lib/liam/MMDrawerBarButtonView.rb', line 126 def touchesEnded(touches, withEvent:event) super self.setNeedsDisplay end |