Sha256: 5544a62178b7246fc5b71e35a31c60ae040bcccfd874aababe1636bbfef2686c
Contents?: true
Size: 1.59 KB
Versions: 1
Compression:
Stored size: 1.59 KB
Contents
# # This module handles all sorts of things related to fonts # and text attributes # module UnderOs::UI class Style module Fonts def fontFamily @view.font.familyName end def fontFamily=(value) @view.font = UIFont.fontWithName(value, size: @view.font.pointSize) end def fontSize @view.font.pointSize end def fontSize=(value) @view.font = @view.font.fontWithSize(value) @view.sizeToFit if @type == :icon end def textAlign if @view.is_a?(UIButton) BUTTONS_ALIGMENTS_MAP.key(@view.contentHorizontalAlignment) elsif @view.respond_to?(:textAlignment) TEXTNODES_ALIGMENTS_MAP.key(@view.textAlignment) end end def textAlign=(value) if @view.is_a?(UIButton) @view.contentHorizontalAlignment = BUTTONS_ALIGMENTS_MAP[value.to_s] || BUTTONS_ALIGMENTS_MAP['left'] elsif @view.respond_to?(:textAlignment) @view.textAlignment = TEXTNODES_ALIGMENTS_MAP[value.to_s] || BUTTONS_ALIGMENTS_MAP['left'] end end BUTTONS_ALIGMENTS_MAP = { 'right' => UIControlContentHorizontalAlignmentRight, 'center' => UIControlContentHorizontalAlignmentCenter, 'justify' => UIControlContentHorizontalAlignmentFill, 'left' => UIControlContentHorizontalAlignmentLeft } TEXTNODES_ALIGMENTS_MAP = { 'right' => NSTextAlignmentRight, 'center' => NSTextAlignmentCenter, 'justify' => NSTextAlignmentJustified, 'left' => NSTextAlignmentLeft } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
under-os-ui-1.4.0 | lib/under_os/ui/style/fonts.rb |