123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- //
- // KBPushAlertView.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/10/12.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "KBPushAlertView.h"
- @implementation KBPushAlertView
- - (instancetype)initWithFrame:(CGRect)frame text:(NSString *)text
- {
- self = [super initWithFrame:frame];
- if (self) {
- [self initSubViews:text];
- }
- return self;
- }
- - (void)initSubViews:(NSString *)text {
- UIImageView *imgView = [[UIImageView alloc] initWithFrame:self.bounds];
- imgView.image = [UIImage imageNamed:@"pop_noti"];
- imgView.userInteractionEnabled = YES;
- [self addSubview:imgView];
-
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(Fitsize(40), Fitsize(160), self.width-Fitsize(80), Fitsize(80))];
- label.textColor = [UIColor YHColorWithHex:0x444444];
- label.textAlignment = NSTextAlignmentCenter;
- label.font = [UIFont systemFontOfSize:Fitsize(17)];
- label.numberOfLines = 0;
- if ([text isKindOfClass:[NSNull class]]|| text==nil) {
- text = @"";
- }
- NSMutableAttributedString *att = [[NSMutableAttributedString alloc] initWithString:text];
- NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc] init];
- [paragraphStyle setLineSpacing:8];
- [att addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [att length])];
- label.attributedText = att;
- [imgView addSubview:label];
-
- UIButton *sure = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, Fitsize(188), Fitsize(36))];
- [sure setTitle:@"开启通知" forState:UIControlStateNormal];
- sure.titleLabel.font = [UIFont systemFontOfSize:Fitsize(18)];
- [sure setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- [sure setBackgroundColor:[UIColor homeRedColor]];
- sure.layer.cornerRadius = Fitsize(5);
- [sure addTarget:self action:@selector(suerClick) forControlEvents:UIControlEventTouchUpInside];
- [imgView addSubview:sure];
- sure.centerX = self.width/2;
-
- UIButton *cancel = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, Fitsize(188), Fitsize(36))];
- [cancel setTitle:@"下次再说" forState:UIControlStateNormal];
- cancel.titleLabel.font = [UIFont systemFontOfSize:Fitsize(16)];
- cancel.titleLabel.textAlignment = NSTextAlignmentCenter;
- [cancel addTarget:self action:@selector(cancelClick) forControlEvents:UIControlEventTouchUpInside];
- [cancel setTitleColor:[UIColor YHColorWithHex:0x888888] forState:UIControlStateNormal];
- [imgView addSubview:cancel];
- cancel.centerX = self.width/2;
-
- sure.bottom = self.height-Fitsize(20);
- cancel.bottom = sure.top-5;
-
- }
- - (void)cancelClick {
- if (self.cancelBlock) {
- self.cancelBlock();
- }
- }
- - (void)suerClick {
- if (self.sureBlock) {
- self.sureBlock();
- }
- }
- @end
|