ifish/Ifish/controllers/message/views/MessageAlertView.m

102 lines
3.6 KiB
Objective-C

//
// MessageAlertView.m
// Ifish
//
// Created by wbzhan on 2019/5/20.
// Copyright © 2019 lianlian. All rights reserved.
//
#import "MessageAlertView.h"
@implementation MessageAlertView
-(instancetype)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [UIColor blackColor];
UIRectCorner rectCorner = UIRectCornerBottomLeft|UIRectCornerBottomRight;
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:RECT(0, 0, kSizeFrom750(220), kSizeFrom750(90)) byRoundingCorners:rectCorner cornerRadii:CGSizeMake(kSizeFrom750(6), kSizeFrom750(6))];
CAShapeLayer *shaperLayer = [CAShapeLayer layer];
shaperLayer.path = path.CGPath;
self.layer.mask = shaperLayer;
CAShapeLayer *borderLayer=[CAShapeLayer layer];
borderLayer.path = path.CGPath;
borderLayer.fillColor = [UIColor clearColor].CGColor;
// borderLayer.strokeColor = [UIColor blackColor].CGColor;
// borderLayer.lineWidth = 1;
borderLayer.frame = self.bounds;
[self initSubViews];
}
return self;
}
-(void)initSubViews
{
NSArray *imageArr = @[@"ifishdropview_delect_device"];
NSArray *titleArr = @[@"删除"];
CGFloat contentHeight = kSizeFrom750(90);
for (int i=0; i<imageArr.count; i++) {
UIImageView *icons = [[UIImageView alloc]init];
// [icons setContentMode:UIViewContentModeCenter];
[self addSubview:icons];
[icons setImage:IMAGEBYENAME([imageArr objectAtIndex:i])];
[icons mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(kSizeFrom750(22)+contentHeight*i);
make.left.mas_equalTo(kSizeFrom750(30));
make.width.height.mas_equalTo(kSizeFrom750(46));
}];
UILabel *titleL = InitObject(UILabel);
[titleL setTextColor:[UIColor whiteColor]];
[titleL setFont:SYSTEMSIZE(30)];
titleL.textAlignment = NSTextAlignmentCenter;
[titleL setText:[titleArr objectAtIndex:i]];
[self addSubview:titleL];
[titleL mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(icons.mas_right);
make.right.mas_equalTo(self);
make.centerY.mas_equalTo(icons);
make.height.mas_equalTo(kSizeFrom750(30));
}];
if (i!=imageArr.count-1) {
UIView *line = InitObject(UIView);
[line setBackgroundColor:[UIColor whiteColor]];
[self addSubview:line];
[line mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(icons.mas_right);
make.height.mas_equalTo(1);
make.right.mas_equalTo(self);
make.bottom.mas_equalTo(icons);
}];
}
UIButton *btn = InitObject(UIButton);
[self addSubview:btn];
btn.tag = i;
[btn addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
[btn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(contentHeight*i);
make.left.right.mas_equalTo(self);
make.height.mas_equalTo(contentHeight);
}];
}
}
-(void)buttonClick:(UIButton *)sender{
if (self.comboxBlock) {
self.comboxBlock(sender.tag);
}
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
@end