// // LDnoticeView.m // YouHuiProject // // Created by liuxueli on 2019/3/6. // Copyright © 2019 kuxuan. All rights reserved. // #import "LDnoticeView.h" @implementation LDnoticeView -(instancetype)initWithFrame:(CGRect)frame { self =[super initWithFrame:frame]; if (self) { self.backgroundColor =[UIColor clearColor]; UIView *whiteView =[[UIView alloc]initWithFrame:CGRectMake(0, 0, FITSIZE(250), FITSIZE(294))]; whiteView.backgroundColor=[UIColor whiteColor]; whiteView.centerY =self.centerY; whiteView.centerX = self.centerX; whiteView.layer.cornerRadius=8; whiteView.layer.masksToBounds = YES; [self addSubview:whiteView]; UIImageView *back_img =[[UIImageView alloc]initWithFrame:CGRectMake(FITSIZE(78), -FITSIZE(33), FITSIZE(94), FITSIZE(90))]; back_img.centerX = self.centerX; back_img.top = whiteView.top-FITSIZE(37); back_img.image =[UIImage imageNamed:@"notice_img"]; [self addSubview:back_img]; UILabel *titlel =[[UILabel alloc]initWithFrame:CGRectMake(0, FITSIZE(71), whiteView.width, FITSIZE(25))]; titlel.textAlignment =NSTextAlignmentCenter; titlel.text=@"开启消息推送通知"; titlel.font =[UIFont boldSystemFontOfSize:FITSIZE(18)]; titlel.textColor=[UIColor YHColorWithHex:0x333333]; [whiteView addSubview:titlel]; UIButton *oneBtn =[[UIButton alloc]initWithFrame:CGRectMake(FITSIZE(28), titlel.bottom+FITSIZE(18), whiteView.width-FITSIZE(56), FITSIZE(20))]; [oneBtn setTitle:@"第一时间掌握优惠商品信息" forState:UIControlStateNormal]; [oneBtn setImage:[UIImage imageNamed:@"notice_yh"] forState:UIControlStateNormal]; [oneBtn setButtonStyle:WSLButtonStyleImageLeft spacing:5]; [oneBtn setTitleColor:[UIColor YHColorWithHex:0x333333] forState:UIControlStateNormal]; oneBtn.titleLabel.font =[UIFont systemFontOfSize:FITSIZE(14)]; [whiteView addSubview:oneBtn]; oneBtn.contentHorizontalAlignment =UIControlContentHorizontalAlignmentLeft; UIButton *twoBtn =[[UIButton alloc]initWithFrame:CGRectMake(FITSIZE(28), oneBtn.bottom+FITSIZE(13), whiteView.width-FITSIZE(56), FITSIZE(20))]; [twoBtn setTitle:@"实时掌握收益动态" forState:UIControlStateNormal]; [twoBtn setImage:[UIImage imageNamed:@"notice_sy"] forState:UIControlStateNormal]; [twoBtn setButtonStyle:WSLButtonStyleImageLeft spacing:5]; [twoBtn setTitleColor:[UIColor YHColorWithHex:0x333333] forState:UIControlStateNormal]; twoBtn.titleLabel.font =[UIFont systemFontOfSize:FITSIZE(14)]; [whiteView addSubview:twoBtn]; twoBtn.contentHorizontalAlignment =UIControlContentHorizontalAlignmentLeft; UIButton *openNoticeBtn =[[UIButton alloc]initWithFrame:CGRectMake(FITSIZE(28), twoBtn.bottom+FITSIZE(28), whiteView.width-FITSIZE(56), FITSIZE(35))]; [openNoticeBtn setTitle:@"开启通知" forState:UIControlStateNormal]; openNoticeBtn.backgroundColor = [UIColor gradientWidthFromColor:[UIColor YHColorWithHex:0xFA2A37] toColor:[UIColor YHColorWithHex:0xFC7123] withWidth:whiteView.width-FITSIZE(56)]; openNoticeBtn.titleLabel.font =[UIFont systemFontOfSize:FITSIZE(15)]; openNoticeBtn.layer.cornerRadius =6; openNoticeBtn.layer.masksToBounds=YES; [openNoticeBtn addTarget:self action:@selector(openNoticeClick) forControlEvents:UIControlEventTouchUpInside]; [whiteView addSubview:openNoticeBtn]; UIButton *closeNoticeBtn =[[UIButton alloc]initWithFrame:CGRectMake(FITSIZE(28), openNoticeBtn.bottom+FITSIZE(14), whiteView.width-FITSIZE(56), FITSIZE(35))]; [closeNoticeBtn setTitle:@"残忍拒绝" forState:UIControlStateNormal]; closeNoticeBtn.backgroundColor = [UIColor colorWithRed:244/255.0 green:244/255.0 blue:244/255.0 alpha:1.0]; closeNoticeBtn.titleLabel.font =[UIFont systemFontOfSize:FITSIZE(15)]; closeNoticeBtn.layer.cornerRadius =6; closeNoticeBtn.layer.masksToBounds=YES; [closeNoticeBtn setTitleColor:[UIColor YHColorWithHex:0xB0B0B0] forState:UIControlStateNormal]; [closeNoticeBtn addTarget:self action:@selector(closeNoticeClick) forControlEvents:UIControlEventTouchUpInside]; [whiteView addSubview:closeNoticeBtn]; } return self; } -(void)openNoticeClick { if (self.clickBlock) { self.clickBlock(); } } -(void)closeNoticeClick { if (self.closeBlock) { self.closeBlock(); } } @end