Class: PMXLBrightnessSlider

Inherits:
UISlider
  • Object
show all
Defined in:
lib/ProMotion/XLForm/cells/xl_form_color_selector_cell.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#color_pickerObject

Returns the value of attribute color_picker.



125
126
127
# File 'lib/ProMotion/XLForm/cells/xl_form_color_selector_cell.rb', line 125

def color_picker
  @color_picker
end

Instance Method Details

#drawRect(rect) ⇒ Object



156
157
158
159
160
161
162
163
164
165
# File 'lib/ProMotion/XLForm/cells/xl_form_color_selector_cell.rb', line 156

def drawRect(rect)
  ctx = UIGraphicsGetCurrentContext()

  space = CGColorSpaceCreateDeviceGray()
  colors = [UIColor.blackColor, UIColor.whiteColor]

  gradient = CGGradientCreateWithColors(space, colors, nil)

  CGContextDrawLinearGradient(ctx, gradient, CGPointZero, [rect.size.width, 0], 0)
end

#init_routineObject



139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/ProMotion/XLForm/cells/xl_form_color_selector_cell.rb', line 139

def init_routine
  self.minimumValue = 0.0
  self.maximumValue = 1.0
  self.continuous = true

  self.enabled = true
  self.userInteractionEnabled = true

  self.addTarget(self,
                 action: 'slider_value_changed:',
                 forControlEvents: UIControlEventValueChanged)
end

#initWithCoder(decoder) ⇒ Object



133
134
135
136
137
# File 'lib/ProMotion/XLForm/cells/xl_form_color_selector_cell.rb', line 133

def initWithCoder(decoder)
  super.tap do
    init_routine
  end
end

#initWithFrame(frame) ⇒ Object



127
128
129
130
131
# File 'lib/ProMotion/XLForm/cells/xl_form_color_selector_cell.rb', line 127

def initWithFrame(frame)
  super.tap do
    init_routine
  end
end

#slider_value_changed(_) ⇒ Object



152
153
154
# File 'lib/ProMotion/XLForm/cells/xl_form_color_selector_cell.rb', line 152

def slider_value_changed(_)
  color_picker.setBrightness(self.value)
end