@@ -27,10 +27,10 @@ - (instancetype)init
2727
2828 self = [super init ];
2929 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 ;
3434 CGFloat viewHeight = _padding_top + _padding_bottom + _image_width * _ratio;
3535 [self setSize: CGSizeMake (kScreen_Width , viewHeight)];
3636 }
@@ -42,53 +42,10 @@ - (void)setCurBannerList:(NSArray *)curBannerList{
4242 return ;
4343 }
4444 _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-
8745 if (!_mySlideView) {
8846 _mySlideView = ({
8947 __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 ];
9249 slideView.layer .masksToBounds = YES ;
9350 slideView.scrollView .scrollsToTop = NO ;
9451
@@ -108,10 +65,10 @@ - (void)setCurBannerList:(NSArray *)curBannerList{
10865 slideView.currentPageIndexChangeBlock = ^(NSInteger currentPageIndex){
10966 if (weakSelf.curBannerList .count > currentPageIndex) {
11067 CodingBanner *curBanner = weakSelf.curBannerList [currentPageIndex];
111- weakSelf.typeLabel .text = curBanner.name ;
68+ weakSelf.typeLabel .text = curBanner.displayName ;
11269 weakSelf.titleLabel .text = curBanner.title ;
11370 }else {
114- weakSelf.typeLabel .text = weakSelf.titleLabel .text = @" ..." ;
71+ weakSelf.typeLabel .text = weakSelf.titleLabel .text = @" ... " ;
11572 }
11673 weakSelf.myPageControl .currentPage = currentPageIndex;
11774 };
@@ -120,11 +77,54 @@ - (void)setCurBannerList:(NSArray *)curBannerList{
12077 weakSelf.tapActionBlock (weakSelf.curBannerList [pageIndex]);
12178 }
12279 };
123-
12480 slideView;
12581 });
12682 [self addSubview: _mySlideView];
12783 }
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+ }];
128128 [self reloadData ];
129129 NSLog (@" %@ " , _curBannerList);
130130}
@@ -162,7 +162,7 @@ - (void)reloadData{
162162 NSInteger currentPageIndex = MIN (self.mySlideView .currentPageIndex , _curBannerList.count - 1 ) ;
163163 CodingBanner *curBanner = _curBannerList[currentPageIndex];
164164 _titleLabel.text = curBanner.title ;
165- _typeLabel.text = curBanner.name ;
165+ _typeLabel.text = curBanner.displayName ;
166166
167167 _myPageControl.numberOfPages = _curBannerList.count ;
168168 _myPageControl.currentPage = currentPageIndex;
0 commit comments