module BubbleWrap::Font
Public Instance Methods
attributes(params = {})
click to toggle source
I.e. for UINavigationBar#titleTextAttributes
# File motion/font/font.rb, line 69 def attributes(params = {}) _attributes = {} _attributes[UITextAttributeFont] = Font.new(params[:font]) if params[:font] _attributes[UITextAttributeTextColor] = params[:color].to_color if params[:color] _attributes[UITextAttributeTextShadowColor] = params[:shadow_color].to_color if params[:shadow_color] _attributes[UITextAttributeTextShadowOffset] = begin x = params[:shadow_offset][:x] y = params[:shadow_offset][:y] offset = UIOffsetMake(x,y) NSValue.valueWithUIOffset(offset) end if params[:shadow_offset] _attributes end
bold(size = nil)
click to toggle source
# File motion/font/font.rb, line 5 def bold(size = nil) Font.new(:bold, size) end
italic(size = nil)
click to toggle source
# File motion/font/font.rb, line 13 def italic(size = nil) Font.new(:italic, size) end
new(params = {}, *args)
click to toggle source
Example Font.new
(<# UIFont >) Font.new
(“Helvetica”) Font.new
(“Helvetica”, 12) Font.new
(“Helvetica”, size: 12) Font.new
(name: “Helvetica”, size: 12)
# File motion/font/font.rb, line 23 def new(params = {}, *args) if params.is_a?(UIFont) return params end _font = nil if params.is_a?(NSString) params = {name: params} end if args && !args.empty? case args[0] when NSDictionary params.merge!(args[0]) else params.merge!({size: args[0]}) end end params[:size] ||= UIFont.systemFontSize case params[:name].to_sym when :system _font = UIFont.systemFontOfSize(params[:size].to_f) when :bold _font = UIFont.boldSystemFontOfSize(params[:size].to_f) when :italic _font = UIFont.italicSystemFontOfSize(params[:size].to_f) else begin _font = UIFont.fontWithName(params[:name], size: params[:size]) rescue end end if !_font raise "Invalid font for parameters: #{params.inspect} args #{args.inspect}" end _font end
system(size = nil)
click to toggle source
# File motion/font/font.rb, line 9 def system(size = nil) Font.new(:system, size) end