1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- //
- // KBFiveStartAlertView.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/10/12.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "KBFiveStartAlertView.h"
- @implementation KBFiveStartAlertView
- - (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_fStart"];
- 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
|