Class: UITabBarItem

Inherits:
Object show all
Defined in:
lib/ios/sugarcube-factories/uitabbaritem.rb

Overview

Factory methods for UITabBarItem. I’ve never understood why UITabBarItem makes it so easy to set the view tag, but these methods do not require you to do so.

Class Method Summary collapse

Class Method Details

.bookmarks(options = {}) ⇒ Object



67
68
69
# File 'lib/ios/sugarcube-factories/uitabbaritem.rb', line 67

def bookmarks(options={})
  return self.system(UITabBarSystemItemBookmarks, options)
end

.contacts(options = {}) ⇒ Object



59
60
61
# File 'lib/ios/sugarcube-factories/uitabbaritem.rb', line 59

def contacts(options={})
  return self.system(UITabBarSystemItemContacts, options)
end

.downloads(options = {}) ⇒ Object



75
76
77
# File 'lib/ios/sugarcube-factories/uitabbaritem.rb', line 75

def downloads(options={})
  return self.system(UITabBarSystemItemDownloads, options)
end

.favorites(options = {}) ⇒ Object



43
44
45
# File 'lib/ios/sugarcube-factories/uitabbaritem.rb', line 43

def favorites(options={})
  return self.system(UITabBarSystemItemFavorites, options)
end


47
48
49
# File 'lib/ios/sugarcube-factories/uitabbaritem.rb', line 47

def featured(options={})
  return self.system(UITabBarSystemItemFeatured, options)
end

.history(options = {}) ⇒ Object



63
64
65
# File 'lib/ios/sugarcube-factories/uitabbaritem.rb', line 63

def history(options={})
  return self.system(UITabBarSystemItemHistory, options)
end

.more(options = {}) ⇒ Object



39
40
41
# File 'lib/ios/sugarcube-factories/uitabbaritem.rb', line 39

def more(options={})
  return self.system(UITabBarSystemItemMore, options)
end

.most_recent(options = {}) ⇒ Object



79
80
81
# File 'lib/ios/sugarcube-factories/uitabbaritem.rb', line 79

def most_recent(options={})
  return self.system(UITabBarSystemItemMostRecent, options)
end

.most_viewed(options = {}) ⇒ Object



83
84
85
# File 'lib/ios/sugarcube-factories/uitabbaritem.rb', line 83

def most_viewed(options={})
  return self.system(UITabBarSystemItemMostViewed, options)
end

.recents(options = {}) ⇒ Object



55
56
57
# File 'lib/ios/sugarcube-factories/uitabbaritem.rb', line 55

def recents(options={})
  return self.system(UITabBarSystemItemRecents, options)
end

.search(options = {}) ⇒ Object



71
72
73
# File 'lib/ios/sugarcube-factories/uitabbaritem.rb', line 71

def search(options={})
  return self.system(UITabBarSystemItemSearch, options)
end

.system(type, options = {}) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/ios/sugarcube-factories/uitabbaritem.rb', line 28

def system(type, options={})
  type = type.uitabbarsystemitem if type.respond_to?(:uitabbarsystemitem)
  tag = options.fetch(:tag, 0)
  badge = options[:badge]
  item = self.alloc.initWithTabBarSystemItem(type, tag: tag)
  if badge
    item.badgeValue = badge.to_s
  end
  return item
end

.titled(title, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ios/sugarcube-factories/uitabbaritem.rb', line 7

def titled(title, options={})
  tag = options.fetch(:tag, 0)
  image = options[:image]
  badge = options[:badge]
  if image && image.respond_to?(:uiimage)
    image = image.uiimage
  end
  selected_image = options[:selected_image]
  if selected_image && selected_image.respond_to?(:uiimage)
    selected_image = selected_image.uiimage
  end
  item = self.alloc.initWithTitle(title, image: image, selectedImage: selected_image)
  if tag
    item.tag = tag
  end
  if badge
    item.badgeValue = badge.to_s
  end
  return item
end

.top_rated(options = {}) ⇒ Object



51
52
53
# File 'lib/ios/sugarcube-factories/uitabbaritem.rb', line 51

def top_rated(options={})
  return self.system(UITabBarSystemItemTopRated, options)
end