Sha256: 819524ca0737d37ab2f502f1a923375174c0ad8c98c2f52b0f0b0f00cd0c8299

Contents?: true

Size: 619 Bytes

Versions: 2

Compression:

Stored size: 619 Bytes

Contents

module Motion ; module Xray

  class XrayGradientView < UIView
    attr_accessor :start_color
    attr_accessor :final_color

    def drawRect(rect)
      context = UIGraphicsGetCurrentContext()
      color_space = CGColorSpaceCreateDeviceRGB()
      cgcolors = [
        (start_color || :white).uicolor.CGColor,
        (final_color || :lightgray).uicolor.CGColor,
      ]

      points = [0, 1]

      gradient = CGGradientCreateWithColors(color_space, cgcolors, points.to_pointer(:float))
      CGContextDrawLinearGradient(context, gradient, self.bounds.top_left, self.bounds.bottom_left, 0)
    end

  end

end end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
motion-xray-1.0.6 lib/motion-xray/views/xray_gradient_view.rb
motion-xray-1.0.4 lib/motion-xray/views/xray_gradient_view.rb