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

159 lines
6.0 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 = RGB(40, 40, 40);
}
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)loadInfoWithTitle:(NSArray *)titleArray Icons:(NSArray *)iconsArray
{
CGFloat contentHeight = kSizeFrom750(90);
for (int i=0; i<titleArray.count; i++) {
UIImageView *icons = [[UIImageView alloc]init];
[icons setContentMode:UIViewContentModeScaleAspectFit];
[self addSubview:icons];
[icons setImage:IMAGEBYENAME([iconsArray objectAtIndex:i])];
[icons mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(kSizeFrom750(25)+contentHeight*i);
make.left.mas_equalTo(kSizeFrom750(30));
make.width.height.mas_equalTo(kSizeFrom750(40));
}];
UILabel *titleL = InitObject(UILabel);
[titleL setTextColor:[UIColor whiteColor]];
[titleL setFont:SYSTEMSIZE(30)];
titleL.textAlignment = NSTextAlignmentCenter;
[titleL setText:[titleArray 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));
}];
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.width.mas_equalTo(self);
make.height.mas_equalTo(contentHeight);
}];
if (i!=titleArray.count-1) {
UIView *line = InitObject(UIView);
[line setBackgroundColor:RGB(30, 30, 30)];
[self addSubview:line];
[line mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(ONE_PIXEL_SIZE);
make.left.width.mas_equalTo(self);
make.bottom.mas_equalTo(btn);
}];
}
}
self.frame = RECT(self.frame.origin.x, self.frame.origin.y, self.frame.size.width, kSizeFrom750(90)*titleArray.count);
[self layoutIfNeeded];
UIRectCorner rectCorner = UIRectCornerBottomLeft|UIRectCornerBottomRight;
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:RECT(0, 0, self.frame.size.width, self.frame.size.height) 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.frame = self.bounds;
self.transform = CGAffineTransformScale(self.transform,0.01,0.01);
self.layer.position = CGPointMake(screen_width - kSizeFrom750(220)/2, 0);
self.layer.anchorPoint = CGPointMake(0.5, 0);
self.hidden = YES;
}
-(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