Class: Motion::Xray::XraySectionHeader
- Inherits:
-
UIControl
- Object
- UIControl
- Motion::Xray::XraySectionHeader
- Defined in:
- lib/motion-xray/views/xray_headers.rb
Instance Attribute Summary collapse
-
#text ⇒ Object
Returns the value of attribute text.
-
#tracking_view ⇒ Object
readonly
Returns the value of attribute tracking_view.
Instance Method Summary collapse
- #drawRect(rect) ⇒ Object
- #exposed=(value) ⇒ Object
- #exposed? ⇒ Boolean
- #initWithFrame(frame) ⇒ Object
Instance Attribute Details
#text ⇒ Object
Returns the value of attribute text.
42 43 44 |
# File 'lib/motion-xray/views/xray_headers.rb', line 42 def text @text end |
#tracking_view ⇒ Object (readonly)
Returns the value of attribute tracking_view.
43 44 45 |
# File 'lib/motion-xray/views/xray_headers.rb', line 43 def tracking_view @tracking_view end |
Instance Method Details
#drawRect(rect) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 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 |
# File 'lib/motion-xray/views/xray_headers.rb', line 61 def drawRect(rect) context = UIGraphicsGetCurrentContext() color_space = CGColorSpaceCreateDeviceRGB() if @pressed else cgcolors = [ :white.uicolor.CGColor, :lightgray.uicolor.CGColor, ] end points = [0, 1] gradient = CGGradientCreateWithColors(color_space, cgcolors, points.to_pointer(:float)) CGContextDrawLinearGradient(context, gradient, self.bounds.top_left, self.bounds.bottom_left, 0) text.drawAtPoint([17, 3], withFont: :bold.uifont(11)) CGContextSaveGState(context) triangle_bounds = CGRect.new([0, 0], [20, 20]).shrink(6) :clear.uicolor.setStroke :lightgray.uicolor.setFill if false if @exposed CGContextMoveToPoint(context, triangle_bounds.top_right(true).x, triangle_bounds.top_right(true).y) CGContextAddLineToPoint(context, triangle_bounds.bottom_center(true).x, triangle_bounds.bottom_center(true).y) CGContextAddLineToPoint(context, triangle_bounds.top_left(true).x, triangle_bounds.top_left(true).y) else CGContextMoveToPoint(context, triangle_bounds.top_left(true).x, triangle_bounds.top_left(true).y) CGContextAddLineToPoint(context, triangle_bounds.center_right(true).x, triangle_bounds.center_right(true).y) CGContextAddLineToPoint(context, triangle_bounds.bottom_left(true).x, triangle_bounds.bottom_left(true).y) end end CGContextDrawPath(context, KCGPathFillStroke) CGContextRestoreGState(context) end |
#exposed=(value) ⇒ Object
57 58 59 |
# File 'lib/motion-xray/views/xray_headers.rb', line 57 def exposed=(value) @exposed = !! value end |
#exposed? ⇒ Boolean
53 54 55 |
# File 'lib/motion-xray/views/xray_headers.rb', line 53 def exposed? @exposed end |
#initWithFrame(frame) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/motion-xray/views/xray_headers.rb', line 45 def initWithFrame(frame) super.tap do @exposed = true @pressed = false @tracking_view = XrayTypewriterView.alloc.initWithFrame([[0, 0], [self.frame.size.width, 0]]) end end |