Skip to content

Commit 8f56ad1

Browse files
committed
Added image retrieval
1 parent d3bedaf commit 8f56ad1

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

TOSegmentedControl/TOSegmentedControl.m

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,21 @@ - (void)removeAllItems
245245
self.items = nil;
246246
}
247247

248+
- (nullable UIImage *)imageForItemAtIndex:(NSInteger)index
249+
{
250+
// Make sure the index provided is valid
251+
if (index < 0 || index >= self.items.count) { return nil; }
252+
253+
// Return the item only if it is an image
254+
id item = self.items[index];
255+
if ([item isKindOfClass:[UIImage class]]) {
256+
return item;
257+
}
258+
259+
// Return nil if a label or anything else
260+
return nil;
261+
}
262+
248263
#pragma mark - View Layout -
249264

250265
- (void)layoutSubviews

0 commit comments

Comments
 (0)