Graphics Reference
In-Depth Information
[array
addObject
:
@{
@"name"
: [
self
randomName
],
@"image"
: [
self
randomAvatar
]
}
];
}
self
.
items
= array;
//register cell class
[
self
.
tableView
registerClass
:[
UITableViewCell
class
]
forCellReuseIdentifier
:
@"Cell"
];
}
- (
NSInteger
)tableView:(
UITableView
*)tableView
numberOfRowsInSection:(
NSInteger
)section
{
return
[
self
.
items
count
];
}
- (
UITableViewCell
*)tableView:(
UITableView
*)tableView
cellForRowAtIndexPath:(
NSIndexPath
*)indexPath
{
//dequeue cell
UITableViewCell
*cell =
[
self
.
tableView
dequeueReusableCellWithIdentifier
:
@"Cell"
forIndexPath
:indexPath];
//load image
NSDictionary
*item =
self
.
items
[indexPath.
row
];
NSString
*filePath = [[
NSBundle
mainBundle
]
pathForResource
:item[
@"image"
]
ofType
:
@"png"
];
//set image and text
cell.
imageView
.
image
= [
UIImage
imageWithContentsOfFile
:filePath];
cell.
textLabel
.
text
= item[
@"name"
];
//set image shadow
cell.
imageView
.
layer
.
shadowOffset
=
CGSizeMake
(
0
,
5
);
cell.
imageView
.
layer
.
shadowOpacity
=
0.75
;
cell.clipsToBounds =
YES
;
//set text shadow
cell.
textLabel
.
backgroundColor
= [
UIColor
clearColor
];
cell.
textLabel
.
layer
.
shadowOffset
=
CGSizeMake
(
0
,
2
);
cell.
textLabel
.
layer
.
shadowOpacity
=
0.5
;