12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- //
- // KBUpdateAlertView.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/10/15.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "KBUpdateAlertView.h"
- @implementation KBUpdateAlertView
- - (instancetype)initWithFrame:(CGRect)frame text:(NSString *)text isNeeded:(BOOL)isNeeded
- {
- self = [super initWithFrame:frame];
- if (self) {
- [self initSubViews:text isNeeded:isNeeded];
- }
- return self;
- }
- - (void)initSubViews:(NSString *)text isNeeded:(BOOL)isNeeded{
- UIImageView *imgView = [[UIImageView alloc] initWithFrame:self.bounds];
- imgView.image = [UIImage imageNamed:@"pop_upda"];
- imgView.userInteractionEnabled = YES;
- [self addSubview:imgView];
-
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(Fitsize(20), Fitsize(190), self.width-Fitsize(40), Fitsize(120))];
- label.textColor = [UIColor YHColorWithHex:0x444444];
- label.textAlignment = NSTextAlignmentCenter;
- label.font = [UIFont systemFontOfSize:Fitsize(15)];
- label.numberOfLines = 0;
- if ([text isKindOfClass:[NSNull class]]|| text==nil) {
- text = @"";
- }
- NSMutableAttributedString *att = [[NSMutableAttributedString alloc] initWithString:text];
- NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc] init];
- [paragraphStyle setLineSpacing:4];
- [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;
- cancel.hidden = isNeeded;
- 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
|