@@ -27,10 +27,10 @@ - (instancetype)init
27
27
28
28
self = [super init ];
29
29
if (self) {
30
- _padding_top = 40 ;
31
- _padding_bottom = 15 ;
32
- _image_width = kScreen_Width - 2 * kPaddingLeftWidth ;
33
- _ratio = 0.3 ;
30
+ _padding_top = 0 ;
31
+ _padding_bottom = 40 ;
32
+ _image_width = kScreen_Width ;
33
+ _ratio = 0.4 ;
34
34
CGFloat viewHeight = _padding_top + _padding_bottom + _image_width * _ratio;
35
35
[self setSize: CGSizeMake (kScreen_Width , viewHeight)];
36
36
}
@@ -42,53 +42,10 @@ - (void)setCurBannerList:(NSArray *)curBannerList{
42
42
return ;
43
43
}
44
44
_curBannerList = curBannerList;
45
-
46
- if (!_typeLabel) {
47
- _typeLabel = ({
48
- UILabel *label = [[UILabel alloc ] initWithFrame: CGRectMake (kPaddingLeftWidth , (_padding_top - 15 )/2 , 30 , 15 )];
49
- [label doBorderWidth: 0.5 color: [UIColor colorWithHexString: @" 0xb5b5b5" ] cornerRadius: 2.0 ];
50
- label.textColor = kColor666 ;
51
- label.font = [UIFont systemFontOfSize: 10 ];
52
- label.textAlignment = NSTextAlignmentCenter;
53
- label.text = @" 活动" ;
54
- label;
55
- });
56
- _typeLabel.text = [(CodingBanner *)_curBannerList.firstObject name ];
57
- [self addSubview: _typeLabel];
58
- }
59
-
60
- if (!_titleLabel) {
61
- _titleLabel = ({
62
- UILabel *label = [[UILabel alloc ] initWithFrame: CGRectMake (CGRectGetMaxX (_typeLabel.frame) + 5.0 , (_padding_top - 30 )/2 , _image_width - CGRectGetWidth (_typeLabel.frame) - 70 , 30 )];
63
- label.textColor = kColor222 ;
64
- label.font = [UIFont systemFontOfSize: 12 ];
65
- label;
66
- });
67
- _titleLabel.text = [(CodingBanner *)_curBannerList.firstObject title ];
68
- [self addSubview: _titleLabel];
69
- }
70
-
71
- if (!_myPageControl) {
72
- _myPageControl = ({
73
- SMPageControl *pageControl = [[SMPageControl alloc ] init ];
74
- pageControl.userInteractionEnabled = NO ;
75
- pageControl.backgroundColor = [UIColor clearColor ];
76
- pageControl.pageIndicatorImage = [UIImage imageNamed: @" banner__page_unselected" ];
77
- pageControl.currentPageIndicatorImage = [UIImage imageNamed: @" banner__page_selected" ];
78
- pageControl.frame = (CGRect ){CGRectGetMaxX (_titleLabel.frame ) + 5 , (_padding_top - 10 )/2 , kScreen_Width - CGRectGetMaxX (_titleLabel.frame ) - kPaddingLeftWidth - 5 , 10 };
79
- pageControl.numberOfPages = _curBannerList.count ;
80
- pageControl.currentPage = 0 ;
81
- pageControl.alignment = SMPageControlAlignmentRight;
82
- pageControl;
83
- });
84
- [self addSubview: _myPageControl];
85
- }
86
-
87
45
if (!_mySlideView) {
88
46
_mySlideView = ({
89
47
__weak typeof (self) weakSelf = self;
90
- AutoSlideScrollView *slideView = [[AutoSlideScrollView alloc ] initWithFrame: CGRectMake (kPaddingLeftWidth , _padding_top, _image_width, _image_width * _ratio) animationDuration: 5.0 ];
91
- // slideView.layer.cornerRadius = 2.0;
48
+ AutoSlideScrollView *slideView = [[AutoSlideScrollView alloc ] initWithFrame: CGRectMake (0 , _padding_top, _image_width, _image_width * _ratio) animationDuration: 5.0 ];
92
49
slideView.layer .masksToBounds = YES ;
93
50
slideView.scrollView .scrollsToTop = NO ;
94
51
@@ -108,10 +65,10 @@ - (void)setCurBannerList:(NSArray *)curBannerList{
108
65
slideView.currentPageIndexChangeBlock = ^(NSInteger currentPageIndex){
109
66
if (weakSelf.curBannerList .count > currentPageIndex) {
110
67
CodingBanner *curBanner = weakSelf.curBannerList [currentPageIndex];
111
- weakSelf.typeLabel .text = curBanner.name ;
68
+ weakSelf.typeLabel .text = curBanner.displayName ;
112
69
weakSelf.titleLabel .text = curBanner.title ;
113
70
}else {
114
- weakSelf.typeLabel .text = weakSelf.titleLabel .text = @" ..." ;
71
+ weakSelf.typeLabel .text = weakSelf.titleLabel .text = @" ... " ;
115
72
}
116
73
weakSelf.myPageControl .currentPage = currentPageIndex;
117
74
};
@@ -120,11 +77,54 @@ - (void)setCurBannerList:(NSArray *)curBannerList{
120
77
weakSelf.tapActionBlock (weakSelf.curBannerList [pageIndex]);
121
78
}
122
79
};
123
-
124
80
slideView;
125
81
});
126
82
[self addSubview: _mySlideView];
127
83
}
84
+ if (!_myPageControl) {
85
+ _myPageControl = ({
86
+ SMPageControl *pageControl = [[SMPageControl alloc ] initWithFrame: CGRectMake (kScreen_Width - kPaddingLeftWidth - 30 , _mySlideView.bottom + (40 - 10 )/2 , 30 , 10 )];
87
+ pageControl.userInteractionEnabled = NO ;
88
+ pageControl.backgroundColor = [UIColor clearColor ];
89
+ pageControl.pageIndicatorImage = [UIImage imageNamed: @" banner__page_unselected" ];
90
+ pageControl.currentPageIndicatorImage = [UIImage imageNamed: @" banner__page_selected" ];
91
+ pageControl.numberOfPages = _curBannerList.count ;
92
+ pageControl.currentPage = 0 ;
93
+ pageControl.alignment = SMPageControlAlignmentRight;
94
+ pageControl;
95
+ });
96
+ [self addSubview: _myPageControl];
97
+ }
98
+
99
+ if (!_typeLabel) {
100
+ _typeLabel = ({
101
+ UILabel *label = [UILabel labelWithFont: [UIFont systemFontOfSize: 10 ] textColor: kColor666 ];
102
+ [label setContentHuggingPriority: UILayoutPriorityRequired forAxis: UILayoutConstraintAxisHorizontal];
103
+ [label setContentCompressionResistancePriority: UILayoutPriorityRequired forAxis: UILayoutConstraintAxisHorizontal];
104
+ [label doBorderWidth: 0.5 color: nil cornerRadius: 2.0 ];
105
+ label.textAlignment = NSTextAlignmentCenter;
106
+ label.text = @" 活动 " ;
107
+ label;
108
+ });
109
+ _typeLabel.text = [(CodingBanner *)_curBannerList.firstObject displayName ];
110
+ [self addSubview: _typeLabel];
111
+ }
112
+
113
+ if (!_titleLabel) {
114
+ _titleLabel = [UILabel labelWithFont: [UIFont systemFontOfSize: 12 ] textColor: kColor222 ];
115
+ _titleLabel.text = [(CodingBanner *)_curBannerList.firstObject title ];
116
+ [self addSubview: _titleLabel];
117
+ }
118
+ [_typeLabel mas_makeConstraints: ^(MASConstraintMaker *make) {
119
+ make.left .equalTo (self).offset (kPaddingLeftWidth );
120
+ make.centerY .equalTo (_myPageControl);
121
+ make.height .mas_equalTo (15 );
122
+ }];
123
+ [_titleLabel mas_makeConstraints: ^(MASConstraintMaker *make) {
124
+ make.left .equalTo (_typeLabel.mas_right ).offset (5 );
125
+ make.right .equalTo (_myPageControl.mas_left ).offset (-5 );
126
+ make.centerY .equalTo (_myPageControl);
127
+ }];
128
128
[self reloadData ];
129
129
NSLog (@" %@ " , _curBannerList);
130
130
}
@@ -162,7 +162,7 @@ - (void)reloadData{
162
162
NSInteger currentPageIndex = MIN (self.mySlideView .currentPageIndex , _curBannerList.count - 1 ) ;
163
163
CodingBanner *curBanner = _curBannerList[currentPageIndex];
164
164
_titleLabel.text = curBanner.title ;
165
- _typeLabel.text = curBanner.name ;
165
+ _typeLabel.text = curBanner.displayName ;
166
166
167
167
_myPageControl.numberOfPages = _curBannerList.count ;
168
168
_myPageControl.currentPage = currentPageIndex;
0 commit comments