1 Star 0 Fork 0

请叫我小鹏哥儿/LYCamera

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
LYUploadImgViewCell.m 2.07 KB
一键复制 编辑 原始数据 按行查看 历史
dayan 提交于 2020-08-17 10:28 . submit first
#import "LYUploadImgViewCell.h"
#import "LYUploadImgModel.h"
typedef void(^ DeleteBlock)(NSInteger);
@interface LYUploadImgViewCell ()
@property (nonatomic, strong) UIImageView *ivImg;
@property (nonatomic, strong) UIButton *bDelete;
@property (nonatomic) NSInteger index;
@property (nonatomic, copy) DeleteBlock block;
@end
@implementation LYUploadImgViewCell
-(instancetype)initWithFrame:(CGRect)frame
{
if (self == [super initWithFrame:frame]) {
self.backgroundColor = [UIColor whiteColor];
//图片
self.ivImg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
self.ivImg.backgroundColor = [UIColor whiteColor];
self.ivImg.layer.cornerRadius = 5;
self.ivImg.layer.masksToBounds = YES;
[self addSubview:self.ivImg];
//删除按钮
CGFloat btnWidth = 15;
self.bDelete = [[UIButton alloc] initWithFrame:CGRectMake(self.frame.size.width - btnWidth, 0, btnWidth, btnWidth)];
[self.bDelete setImage:[UIImage imageNamed:@"icon_delete_img"] forState:UIControlStateNormal];
self.bDelete.backgroundColor = [UIColor whiteColor];
self.bDelete.layer.cornerRadius = btnWidth / 2;
self.bDelete.layer.masksToBounds = YES;
[self.bDelete addTarget:self action:@selector(deleteAction) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:self.bDelete];
}
return self;
}
-(void)deleteAction{
if (_block) {
_block(_index);
}
}
-(void)deleteImgSelectWithBlock:(void (^)(NSInteger))block{
_block = block;
}
-(void)setDataSourceWithModel:(LYUploadImgModel *)model Index:(NSInteger)index{
_index = index;
[self.ivImg setImage:model.img];
//占位图的时候不显示删除按钮
if (model.imgType == 1) {
self.ivImg.layer.cornerRadius = 0;
self.bDelete.hidden = YES;
}
//非占位图的时候显示删除按钮
else{
self.ivImg.layer.cornerRadius = 5;
self.bDelete.hidden = NO;
}
}
@end
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zangshipeng/LYCamera.git
git@gitee.com:zangshipeng/LYCamera.git
zangshipeng
LYCamera
LYCamera
master

搜索帮助