12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- //
- // DRUpdatePopView.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/5/9.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "DRUpdatePopView.h"
- @implementation DRUpdatePopView
- - (instancetype)initWithFrame:(CGRect)frame searchText:(NSString *)searchText isNeed:(BOOL)isNeed{
- self = [super initWithFrame:frame];
- if (self) {
- self.layer.cornerRadius = 6;
- self.layer.masksToBounds = YES;
- self.backgroundColor = [UIColor whiteColor];
- [self initSubViewWithText:searchText isNeed:isNeed];
- }
- return self;
- }
- - (void)initSubViewWithText:(NSString *)searchText isNeed:(BOOL)isNeed{
- UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.width, Fitsize(85))];
- imageView.image = [UIImage imageNamed:@"update_top"];
- [self addSubview:imageView];
-
-
- UILabel *desLb = [[UILabel alloc] initWithFrame:CGRectMake(0, imageView.bottom+10, self.width, 17)];
- desLb.text = @"猎豆优选的小伙伴们,我们有新功能啦";
- desLb.font = [UIFont systemFontOfSize:14];
- desLb.textAlignment = NSTextAlignmentCenter;
- desLb.textColor = [UIColor YHColorWithHex:0x666666];
- [self addSubview:desLb];
-
- UILabel *searchLabel = [[UILabel alloc] initWithFrame:CGRectMake(23, imageView.bottom+20, self.width-46, 70)];
- searchLabel.numberOfLines = 3;
- searchLabel.textColor = [UIColor YHColorWithHex:0x262626];
- searchLabel.textAlignment = NSTextAlignmentCenter;
- searchLabel.font = [UIFont systemFontOfSize:14];
- searchLabel.text = [searchText isKindOfClass:[NSNull class]]?@"":searchText;
- [self addSubview:searchLabel];
-
- UIButton *cancelBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, self.height-57, self.width/2, 57)];
- [cancelBtn setTitleColor:[UIColor YHColorWithHex:0x999999] forState:UIControlStateNormal];
- [cancelBtn setTitle:@"以后再说" forState:UIControlStateNormal];
- cancelBtn.titleLabel.font = [UIFont systemFontOfSize:16];
- [cancelBtn addTarget:self action:@selector(cancelAction) forControlEvents:UIControlEventTouchUpInside];
- [self addSubview:cancelBtn];
-
- UIButton *searchBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.width/2, self.height-57, self.width/2, 57)];
- [searchBtn setTitleColor:[UIColor homeRedColor] forState:UIControlStateNormal];
- [searchBtn setTitle:@"马上升级" forState:UIControlStateNormal];
- searchBtn.titleLabel.font = [UIFont systemFontOfSize:16];
- [searchBtn addTarget:self action:@selector(searchClick) forControlEvents:UIControlEventTouchUpInside];
- [self addSubview:searchBtn];
-
- if (isNeed) {
- cancelBtn.hidden = YES;
- searchBtn.x = 0;
- searchBtn.width = self.width;
- }
- }
- - (void)cancelAction {
- if (self.cancelClick) {
- self.cancelClick();
- }
- }
- - (void)searchClick {
- if (self.updateClick) {
- self.updateClick();
- }
- }
- @end
|