ZZPhotoPickerCell.m
2.44 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//
// ZZPhotoPickerCell.m
// ZZFramework
//
// Created by Yuan on 15/7/7.
// Copyright (c) 2015年 zzl. All rights reserved.
//
#import "ZZPhotoPickerCell.h"
@implementation ZZPhotoPickerCell
{
UIImageView *img_play;
}
-(instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
CGFloat photoSize = ([UIScreen mainScreen].bounds.size.width - 3) / 4;
_photo = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, photoSize, photoSize)];
_photo.layer.masksToBounds = YES;
_photo.contentMode = UIViewContentModeScaleAspectFill;
[self.contentView addSubview:_photo];
CGFloat picViewSize = ([UIScreen mainScreen].bounds.size.width - 3) / 4;
CGFloat btnSize = picViewSize / 4;
_selectBtn = [[UIButton alloc]initWithFrame:CGRectMake(picViewSize - btnSize - 5, 5, btnSize, btnSize)];
[self.contentView addSubview:_selectBtn];
CGFloat imgSize = picViewSize / 3;
img_play = [[UIImageView alloc]initWithFrame:CGRectMake((picViewSize-imgSize)/2, (picViewSize-imgSize)/2, imgSize, imgSize)];
img_play.hidden = YES;
[self.contentView addSubview:img_play];
}
return self;
}
- (void)setModel:(id)model
{
_model = model;
}
//记录按钮选中和非选中的状态
-(void)selectBtnStage:(NSMutableArray *)selectArray existence:(ZZPhoto *)photo
{
for (ZZPhoto *photos in selectArray) {
if ([photos.asset isEqual:photo.asset]) {
_selectBtn.selected = YES;
[_selectBtn setImage:Pic_Btn_Selected forState:UIControlStateNormal];
break;
}else{
_selectBtn.selected = NO;
[_selectBtn setImage:Pic_btn_UnSelected forState:UIControlStateNormal];
}
}
if (selectArray.count <1) {
_selectBtn.selected = NO;
[_selectBtn setImage:Pic_btn_UnSelected forState:UIControlStateNormal];
}
}
-(void)loadPhotoData:(ZZPhoto *)assetItem
{
img_play.hidden = YES;
if ([assetItem isKindOfClass:[ZZPhoto class]]) {
[[PHImageManager defaultManager] requestImageForAsset:assetItem.asset targetSize:CGSizeMake(200, 200) contentMode:PHImageContentModeAspectFit options:nil resultHandler:^(UIImage *result, NSDictionary *info){
self.photo.image = result;
}];
}
}
@end