Skip to content
Newer
Older
100644 155 lines (116 sloc) 6.3 KB
f43ac45 @soffes Started on collection view
soffes authored
1 //
2 // SSCollectionViewItem.h
3 // SSToolkit
4 //
5 // Created by Sam Soffes on 6/11/10.
e8c3ce3 @soffes Updated comments and renamed SSDrawingMacros to SSDrawingUtilities
soffes authored
6 // Copyright 2010-2011 Sam Soffes. All rights reserved.
f43ac45 @soffes Started on collection view
soffes authored
7 //
8
f63bf11 @soffes More documentation
soffes authored
9 /**
10 An enumeration for the various styles of items.
11 */
f43ac45 @soffes Started on collection view
soffes authored
12 typedef enum {
f63bf11 @soffes More documentation
soffes authored
13 SSCollectionViewItemStyleDefault = UITableViewCellStyleDefault,
14 SSCollectionViewItemStyleSubtitle = UITableViewCellStyleSubtitle,
cf7dc52 @soffes Added SSCollectionViewItemStyleImage to SSCollectionViewItem and swit…
soffes authored
15 SSCollectionViewItemStyleBlank,
16 SSCollectionViewItemStyleImage
f43ac45 @soffes Started on collection view
soffes authored
17 } SSCollectionViewItemStyle;
18
9947d6f @soffes Added CGSizeAspectScaleToSize
soffes authored
19 @class SSLabel;
a12ab59 @soffes Initial reuse strategy
soffes authored
20 @class SSCollectionView;
f43ac45 @soffes Started on collection view
soffes authored
21
072f882 @soffes More documentation. #24 #25
soffes authored
22 /**
23 View for display in a collection view.
7bb2691 @soffes * Removed SSKeychain
soffes authored
24 */
454e654 @soffes Require Apple LLVM compiler 3.0
soffes authored
25 @interface SSCollectionViewItem : UIView
f43ac45 @soffes Started on collection view
soffes authored
26
072f882 @soffes More documentation. #24 #25
soffes authored
27 /**
28 Returns the image view of the collection view item. (read-only)
7bb2691 @soffes * Removed SSKeychain
soffes authored
29
072f882 @soffes More documentation. #24 #25
soffes authored
30 Returns the image view (`UIImageView` object) of the collection view item, which initially has no image set.
31 `SSCollectionViewItem` creates the image view object when you create the item.
7bb2691 @soffes * Removed SSKeychain
soffes authored
32 */
df98fab @soffes Use strong and unsafe_unretained in properties
soffes authored
33 @property (nonatomic, strong) UIImageView *imageView;
7bb2691 @soffes * Removed SSKeychain
soffes authored
34
072f882 @soffes More documentation. #24 #25
soffes authored
35 /**
36 Returns the label used for the main textual content of the table cell. (read-only)
7bb2691 @soffes * Removed SSKeychain
soffes authored
37
072f882 @soffes More documentation. #24 #25
soffes authored
38 Holds the main label of the item. `SSCollectionViewItem` adds an appropriate label when you create the cell in a given
39 item style.
7bb2691 @soffes * Removed SSKeychain
soffes authored
40 */
df98fab @soffes Use strong and unsafe_unretained in properties
soffes authored
41 @property (nonatomic, strong) SSLabel *textLabel;
7bb2691 @soffes * Removed SSKeychain
soffes authored
42
072f882 @soffes More documentation. #24 #25
soffes authored
43 /**
44 Returns the secondary label of the collection view item. (read-only)
7bb2691 @soffes * Removed SSKeychain
soffes authored
45
072f882 @soffes More documentation. #24 #25
soffes authored
46 Holds the secondary label of the item. `SSCollectionViewItem` adds an appropriate label when you create the cell in a
47 given item style.
7bb2691 @soffes * Removed SSKeychain
soffes authored
48 */
df98fab @soffes Use strong and unsafe_unretained in properties
soffes authored
49 @property (nonatomic, strong) SSLabel *detailTextLabel;
f43ac45 @soffes Started on collection view
soffes authored
50
bf2d0ec @soffes Started overhauling documentation
soffes authored
51 /** The view used as the background of the item.
7bb2691 @soffes * Removed SSKeychain
soffes authored
52
072f882 @soffes More documentation. #24 #25
soffes authored
53 The default is `nil`. `SSCollectionViewItem` adds the background view as a subview behind all other views and uses its
54 current frame location.
7bb2691 @soffes * Removed SSKeychain
soffes authored
55 */
df98fab @soffes Use strong and unsafe_unretained in properties
soffes authored
56 @property (nonatomic, strong) UIView *backgroundView;
7bb2691 @soffes * Removed SSKeychain
soffes authored
57
072f882 @soffes More documentation. #24 #25
soffes authored
58 /**
59 The view used as the background of the item when it is selected.
7bb2691 @soffes * Removed SSKeychain
soffes authored
60
072f882 @soffes More documentation. #24 #25
soffes authored
61 The default is `nil`. `SSCollectionViewItem` adds the value of this property as a subview only when the cell is
62 selected. It adds the selected background view as a subview directly above the background view (`backgroundView`) if it
63 is not `nil`, or behind all other views. Calling `setSelected:animated:` causes the `selectedBackground` view to
64 animate in and out with an alpha fade.
7bb2691 @soffes * Removed SSKeychain
soffes authored
65 */
df98fab @soffes Use strong and unsafe_unretained in properties
soffes authored
66 @property (nonatomic, strong) UIView *selectedBackgroundView;
f43ac45 @soffes Started on collection view
soffes authored
67
072f882 @soffes More documentation. #24 #25
soffes authored
68 /**
69 A string used to identify an item that is reusable. (read-only)
7bb2691 @soffes * Removed SSKeychain
soffes authored
70
072f882 @soffes More documentation. #24 #25
soffes authored
71 The reuse identifier is associated with a `SSCollectionViewItem` object that the collection view's delegate creates
72 with the intent to reuse it as the basis (for performance reasons) for multiple items of a collection view. It is
73 assigned to the item object in `initWithFrame:reuseIdentifier:` and cannot be changed thereafter. A `SSCollectionView`
74 object maintains a queue (or list) of the currently reusable items, each with its own reuse identifier, and makes them
75 available to the delegate in the `dequeueReusableCellWithIdentifier:` method.
7bb2691 @soffes * Removed SSKeychain
soffes authored
76 */
f43ac45 @soffes Started on collection view
soffes authored
77 @property (nonatomic, readonly, copy) NSString *reuseIdentifier;
78
072f882 @soffes More documentation. #24 #25
soffes authored
79 /**
80 A Boolean value that indicates whether the cell is selected.
7bb2691 @soffes * Removed SSKeychain
soffes authored
81
072f882 @soffes More documentation. #24 #25
soffes authored
82 The selection affects the appearance of labels, image, and background. The default value is `NO`.
7bb2691 @soffes * Removed SSKeychain
soffes authored
83
84 @see setSelected:animated:
85 */
f43ac45 @soffes Started on collection view
soffes authored
86 @property (nonatomic, getter=isSelected) BOOL selected;
87
072f882 @soffes More documentation. #24 #25
soffes authored
88 /**
89 A Boolean value that indicates whether the item is highlighted.
7bb2691 @soffes * Removed SSKeychain
soffes authored
90
072f882 @soffes More documentation. #24 #25
soffes authored
91 The highlighting affects the appearance of labels, image, and background. When the the highlighted state of an item is
92 set to `YES`, labels are drawn in their highlighted text color. The default value is `NO`. If you set the highlighted
93 state to `YES` through this property, the transition to the new state appearance is not animated. For animated
94 highlighted-state transitions, see the `setHighlighted:animated:` method.
7bb2691 @soffes * Removed SSKeychain
soffes authored
95
072f882 @soffes More documentation. #24 #25
soffes authored
96 Note that for highlighting to work properly, you must fetch the items's labels using the textLabel and
97 `detailTextLabel` properties and set each label's `highlightedTextColor` property; for images, get the item's image
98 using the `imageView` property and set the `UIImageView` object's `highlightedImage` property.
7bb2691 @soffes * Removed SSKeychain
soffes authored
99
100 @see setHighlighted:animated:
101 */
102 @property (nonatomic, getter=isHighlighted) BOOL highlighted;
f43ac45 @soffes Started on collection view
soffes authored
103
072f882 @soffes More documentation. #24 #25
soffes authored
104 /**
105 Initializes a collection view item with a style and a reuse identifier and returns it to the caller.
f3c6c83 @soffes * Removed injecting CSS in SSWebView since it is rarely used and supe…
soffes authored
106
107 @param style A constant indicating a item style.
108
072f882 @soffes More documentation. #24 #25
soffes authored
109 @param aReuseIdentifier A string used to identify the item object if it is to be reused for drawing multiple items of a
110 collection view. Pass `nil` if the cell object is not to be reused. You should use the same reuse identifier for all
111 cells of the same form.
f3c6c83 @soffes * Removed injecting CSS in SSWebView since it is rarely used and supe…
soffes authored
112
072f882 @soffes More documentation. #24 #25
soffes authored
113 @return An initialized `SSCollectionViewItem` object or nil if the object could not be created.
f3c6c83 @soffes * Removed injecting CSS in SSWebView since it is rarely used and supe…
soffes authored
114 */
7bb2691 @soffes * Removed SSKeychain
soffes authored
115 - (id)initWithStyle:(SSCollectionViewItemStyle)style reuseIdentifier:(NSString *)aReuseIdentifier;
f43ac45 @soffes Started on collection view
soffes authored
116
072f882 @soffes More documentation. #24 #25
soffes authored
117 /**
118 Prepares a reusable item for reuse by the table view's delegate.
7bb2691 @soffes * Removed SSKeychain
soffes authored
119 */
120 - (void)prepareForReuse;
121
072f882 @soffes More documentation. #24 #25
soffes authored
122 /**
123 Sets the selected state of the item, optionally animating the transition between states.
7bb2691 @soffes * Removed SSKeychain
soffes authored
124
fc1acd8 @soffes Updated documentation coding convention
soffes authored
125 The selection affects the appearance of labels, image, and background. When the the selected state of a cell to `YES`,
126 it draws the background for selected items with its title in its `highlightedTextColor`.
127
072f882 @soffes More documentation. #24 #25
soffes authored
128 @param selected `YES` to set the item as selected, `NO` to set it as unselected. The default is `NO`.
7bb2691 @soffes * Removed SSKeychain
soffes authored
129
072f882 @soffes More documentation. #24 #25
soffes authored
130 @param animated `YES` to animate the transition between selected states, `NO` to make the transition immediate.
7bb2691 @soffes * Removed SSKeychain
soffes authored
131 */
f43ac45 @soffes Started on collection view
soffes authored
132 - (void)setSelected:(BOOL)selected animated:(BOOL)animated;
7bb2691 @soffes * Removed SSKeychain
soffes authored
133
072f882 @soffes More documentation. #24 #25
soffes authored
134 /**
135 Sets the highlighted state of the item, optionally animating the transition between states.
7bb2691 @soffes * Removed SSKeychain
soffes authored
136
072f882 @soffes More documentation. #24 #25
soffes authored
137 Highlights or unhighlights the item, animating the transition between regular and highlighted state if animated is
138 `YES`. Highlighting affects the appearance of the items's labels, image, and background.
7bb2691 @soffes * Removed SSKeychain
soffes authored
139
072f882 @soffes More documentation. #24 #25
soffes authored
140 Note that for highlighting to work properly, you must fetch the item's label (or labels) using the `textLabel`
141 (and `detailTextLabel`) properties and set the label's `highlightedTextColor` property; for images, get the items's
142 image using the `imageView` property and set the `UIImageView` object's `highlightedImage` property.
7bb2691 @soffes * Removed SSKeychain
soffes authored
143
144 A custom table item may override this method to make any transitory appearance changes.
fc1acd8 @soffes Updated documentation coding convention
soffes authored
145
146 @param highlighted `YES` to set the item as highlighted, `NO` to set it as
147 unhighlighted. The default is `NO`.
148
149 @param animated `YES` to animate the transition between highlighted states, `NO`
150 to make the transition immediate.
7bb2691 @soffes * Removed SSKeychain
soffes authored
151 */
f43ac45 @soffes Started on collection view
soffes authored
152 - (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated;
153
154 @end
Something went wrong with that request. Please try again.