单军华
2018-03-29 89d748b77b478905732e60f0b4c5807c274b6565
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
//
//  FileDownView.m
//  GoldRich
//
//  Created by WindShan on 2017/2/13.
//  Copyright © 2017年 WindShan. All rights reserved.
//
 
#import "AdNoticeView.h"
#import "GloriaLabel.h"
 
@interface AdNoticeView()<SelectedNoticeDelegate>
{
 
}
 
@property (nonatomic, strong)     UIImageView * noticeBK;
@property (nonatomic, strong)     UIImageView * noticeLogo;
@property (nonatomic, strong)     UIButton * cancelLookBtn;
//@property (nonatomic, strong)     UIButton * lookDetailBtn;
@property (nonatomic, strong)     GloriaLabel * noticeContext;
@property (nonatomic, strong)     GloriaLabel * noticeTitle;
 
@end
 
 
@implementation AdNoticeView
 
- (UIImageView *)noticeLogo
{
    if (!_noticeLogo)
    {
        _noticeLogo =  [[UIImageView alloc] initWithFrame:CGRectMake((258-32)/2, 50, 32, 12)];
        [self.noticeBK addSubview:_noticeLogo];
    }
    
    return _noticeLogo;
}
 
 
- (UIImageView *)noticeBK
{
    if (!_noticeBK)
    {
        _noticeBK =  [[UIImageView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-258)/2, (SCREEN_HEIGHT-168)/2-64, 258, 168)];
        [self.noticeBK setUserInteractionEnabled:YES];
        [self addSubview:_noticeBK];
    }
    
    return _noticeBK;
}
 
- (GloriaLabel *) noticeTitle
{
    if(!_noticeTitle)
    {
        _noticeTitle = [[GloriaLabel alloc] initWithFrame:CGRectMake(0,10,258, 20)];
        _noticeTitle.font = [UIFont systemFontOfSize:16];
        _noticeTitle.textAlignment = UITextAlignmentCenter;
        _noticeTitle.textColor = kUIColorFromRGB(0xffffff);
        [self.noticeBK  addSubview:_noticeTitle];
    }
    
    return _noticeTitle;
}
 
- (GloriaLabel *) noticeContext
{
    if(!_noticeContext)
    {
        _noticeContext = [[GloriaLabel alloc] initWithFrame:CGRectMake(20, 80,258-40, 40)];
        _noticeContext.font = [UIFont systemFontOfSize:14];
        _noticeContext.textAlignment = UITextAlignmentCenter;
        //自动折行设置
        _noticeContext.lineBreakMode = UILineBreakModeWordWrap;
        _noticeContext.numberOfLines = 0;
        _noticeContext.textColor = kUIColorFromRGB(0x414141);
        [self.noticeBK  addSubview:_noticeContext];
    }
    
    return _noticeContext;
}
 
 
-(UIButton*)cancelLookBtn
{
    if(!_cancelLookBtn)
    {
        _cancelLookBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        _cancelLookBtn.frame = CGRectMake((258-76)/2, 130, 76, 26);
         [_cancelLookBtn setBackgroundImage:[UIImage imageNamed:@"cancel_look" ] forState:UIControlStateNormal];
        [_cancelLookBtn setTitle:@"取 消" forState:UIControlStateNormal];
        [_cancelLookBtn setTitleColor:kUIColorFromRGB(0x7d7d7d) forState:UIControlStateNormal];
        //_deleteBtn.backgroundColor = [UIColor redColor];    //上左下右
        
        _cancelLookBtn.titleLabel.font = [UIFont systemFontOfSize: 12.0];
        [_cancelLookBtn addTarget:self action:@selector(CancelClickAction) forControlEvents:UIControlEventTouchUpInside];
        [self.noticeBK  addSubview:_cancelLookBtn];
    }
    
    return _cancelLookBtn;
}
 
//-(UIButton*)lookDetailBtn
//{
//    if(!_lookDetailBtn)
//    {
//        _lookDetailBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
//        _lookDetailBtn.frame = CGRectMake(258-40-76, 168-52, 76, 26);
//        [_lookDetailBtn setBackgroundImage:[UIImage imageNamed:@"look_notice" ] forState:UIControlStateNormal];
//        [_lookDetailBtn setTitle:@"查看详情" forState:UIControlStateNormal];
//        [_lookDetailBtn setTitleColor:kUIColorFromRGB(0xffffff) forState:UIControlStateNormal];
//        //_deleteBtn.backgroundColor = [UIColor redColor];    //上左下右
//
//        _lookDetailBtn.titleLabel.font = [UIFont systemFontOfSize: 12.0];
//        [_lookDetailBtn addTarget:self action:@selector(LookClickAction) forControlEvents:UIControlEventTouchUpInside];
//
//        [_lookDetailBtn setTintColor:RgbColor(253,137,8)];
//
//        [self.noticeBK  addSubview:_lookDetailBtn];
//    }
//
//    return _cancelLookBtn;
//}
 
-(void)CancelClickAction
{
    [self setHidden:YES];
//    // 查看文件
//    if ( _delegate && [_delegate respondsToSelector:@selector(didSelectedNoticeSection:)])
//    {
//        [_delegate didSelectedNoticeSection:self.model];
//    }
}
 
-(void)LookClickAction
{
    // 查看文件
    if ( _delegate && [_delegate respondsToSelector:@selector(didSelectedNoticeSection:)])
    {
        [_delegate didSelectedNoticeSection:self.model];
    }
}
 
- (instancetype)initWithFrame:(CGRect)frame dataModel:(NoticeModel*)model
{
    if (self = [super initWithFrame:frame])
    {        
        //设置 背景为clear
        self.backgroundColor = [UIColor clearColor];
        self.opaque = NO;
        
        // test
        //for (int i = 0; i < 10; i++)
        //{
        //    MyDeviceStatus * status = [[MyDeviceStatus alloc] init];
        //    [self.modelArray addObject:status];
        //}
        // 设置界面
        self.model = model;
        [self setUIView];
    }
    
    return self;
}
 
 
-(void)setUIView
{
    //self.backgroundColor = [UIColor clearColor];
    
    self.noticeBK.image = [UIImage imageNamed:@"notice_bg"];
    self.noticeLogo.image = [UIImage imageNamed:@"img_logo"];
    
    [self.noticeContext setText:[NSString stringWithFormat:@"昨天的PM2.5状况为差\n请您注意身边的污染源"]];
    [self.noticeTitle setText:[NSString stringWithFormat:@"摩瑞尔温馨提醒"]];
   // [self.lookDetailBtn setTitle:@"查看详情" forState:UIControlStateNormal];
    [self.cancelLookBtn setTitle:@"取 消" forState:UIControlStateNormal];
}
 
@end