Sha256: bdbcea320a8cfeaca09730ba471cef6ad3f6672068c1dc16ac5fc775e62170fe

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

motion_require '_key_value_store'
motion_require '_padding_attribute'
motion_require '_control_content_alignment'
class MPButton < UIButton
  include MotionPrime::SupportKeyValueStore
  include MotionPrime::SupportPaddingAttribute
  include MotionPrime::SupportControlContentAlignment

  attr_accessor :sizeToFit

  def setTitle(value)
    setTitle value, forState: UIControlStateNormal
  end

  def setImage(value)
    setImage value, forState: UIControlStateNormal
  end

  def setTitleEdgeInsets(value)
    @custom_title_inset_drawn = true
    super
  end

  def self.default_padding_left
    5
  end

  def self.default_padding_right
    5
  end

  def apply_padding!(rect)
    self.setTitleEdgeInsets(padding_insets)
  end

  def apply_padding?
    # TODO: we should run super method here, but for some reason it doesn't work in RM 2.32
    ![padding_top, padding_left, padding_right, padding_bottom].all?(&:zero?) &&
    !@custom_title_inset_drawn
  end

  def drawRect(rect)
    apply_padding(rect)
    super
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
motion-prime-1.0.7 motion-prime/support/mp_button.rb