Class: IconView
- Inherits:
-
UILabel
- Object
- UILabel
- IconView
- Defined in:
- lib/project/views/icon_view.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #hex ⇒ Object
- #icon_mappings ⇒ Object
- #init ⇒ Object
- #json_data ⇒ Object
- #json_path ⇒ Object
- #unicode ⇒ Object
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/project/views/icon_view.rb', line 2 def name @name end |
Instance Method Details
#hex ⇒ Object
19 20 21 |
# File 'lib/project/views/icon_view.rb', line 19 def hex unicode ? unicode.hex.chr(Encoding::UTF_8) : '' end |
#icon_mappings ⇒ Object
27 28 29 |
# File 'lib/project/views/icon_view.rb', line 27 def icon_mappings @_icon_mappings ||= BW::JSON.parse(json_data.to_str) end |
#init ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/project/views/icon_view.rb', line 4 def init super.tap do |view| view.font = MotionForm.icon_font view.backgroundColor = UIColor.clearColor view.textColor = UIColor.grayColor view.textAlignment = NSTextAlignmentCenter end end |
#json_data ⇒ Object
31 32 33 |
# File 'lib/project/views/icon_view.rb', line 31 def json_data NSData.dataWithContentsOfFile(json_path) end |
#json_path ⇒ Object
35 36 37 |
# File 'lib/project/views/icon_view.rb', line 35 def json_path NSBundle.mainBundle.pathForResource('font_icons', ofType: 'json') end |
#unicode ⇒ Object
23 24 25 |
# File 'lib/project/views/icon_view.rb', line 23 def unicode icon_mappings[name] end |