-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBHAlbumPhotoCell.m
executable file
·66 lines (50 loc) · 1.62 KB
/
BHAlbumPhotoCell.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//
// BHAlbumPhotoCell.m
// CollectionViewTutorial
//
// Created by Bryan Hansen on 11/3/12.
// Copyright (c) 2012 Bryan Hansen. All rights reserved.
//
#import "BHAlbumPhotoCell.h"
#import <QuartzCore/QuartzCore.h>
@interface BHAlbumPhotoCell ()
@property (nonatomic, strong, readwrite) UIImageView *imageView;
@end
@implementation BHAlbumPhotoCell
#pragma mark - Lifecycle
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [UIColor colorWithWhite:0.85f alpha:1.0f];
self.layer.borderColor = [UIColor whiteColor].CGColor;
self.layer.borderWidth = 3.0f;
self.layer.shadowColor = [UIColor blackColor].CGColor;
self.layer.shadowRadius = 3.0f;
self.layer.shadowOffset = CGSizeMake(0.0f, 2.0f);
self.layer.shadowOpacity = 0.5f;
// make sure we rasterize nicely for retina
self.layer.rasterizationScale = [UIScreen mainScreen].scale;
self.layer.shouldRasterize = YES;
self.imageView = [[UIImageView alloc] initWithFrame:self.bounds];
self.imageView.contentMode = UIViewContentModeScaleAspectFill;
self.imageView.clipsToBounds = YES;
[self.contentView addSubview:self.imageView];
}
return self;
}
- (void)prepareForReuse
{
[super prepareForReuse];
self.imageView.image = nil;
}
-(void) setPhotoSelected:(BOOL)selected {
[self setSelected:selected];
if(selected) {
self.layer.borderColor = [UIColor blueColor].CGColor;
}
else {
self.layer.borderColor = [UIColor whiteColor].CGColor;
}
}
@end