123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- //
- // FKProBannerCell.m
- // FirstLink
- //
- // Created by jack on 16/8/12.
- // Copyright © 2016年 FirstLink. All rights reserved.
- //
- #import "FKProBannerCell.h"
- #import "FKProDetailViewModel.h"
- @interface FKProBannerCell () <DPBannerViewDelegate>
- @end
- @implementation FKProBannerCell
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
- [self addAllSubViews];
- }
- return self;
- }
- - (void)addAllSubViews {
- [self.contentView addSubview:self.banerView];
- [self.contentView addSubview:self.pageControl];
- [self.contentView addSubview:self.goToDetailBtn];
- [self.contentView addSubview:self.pageControl];
-
- [self.pageControl mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.banerView);
- make.right.equalTo(self.banerView);
- make.bottom.equalTo(self.banerView).offset(-8);
- make.height.mas_equalTo(20);
- }];
-
- [self.goToDetailBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.contentView).offset(- 10);
- make.bottom.equalTo(self.contentView).offset(- 30);
- make.width.height.mas_equalTo(40);
- }];
-
- [self.pageControl mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.banerView);
- make.right.equalTo(self.banerView);
- make.bottom.equalTo(self.banerView).offset(-8);
- make.height.mas_equalTo(20);
- }];
- }
- - (void)fk_configWithViewModel:(id)viewModel indexPath:(NSIndexPath *)indexPath{
- if ([viewModel isKindOfClass:[FKProDetailViewModel class]]) {
- FKProDetailViewModel *detailModel = (FKProDetailViewModel *)viewModel;
-
- self.banerView.duration = 0.0f;
- self.banerView.imageUrls = detailModel.specPicArray;
- self.pageControl.numberOfPages = detailModel.specPicArray.count;
- }
- }
- - (void)bannerView:(DPBannerView *)bannerView didSelectedAtIndex:(NSInteger)index{
- if (self.clickAction) {
- self.clickAction(index, self);
- }
- }
- - (void)bannerView:(DPBannerView *)bannerView didShowAtIndex:(NSInteger)index{
- self.pageControl.currentPage = index;
- }
- #pragma mark - Property
- - (DPBannerView *)banerView{
- if (_banerView == nil) {
- _banerView = [[DPBannerView alloc]initWithFrame:CGRectMake(0, 0, UISCREENWIDTH, UISCREENWIDTH)];
- // _banerView.backgroundColor = UIColorFromRGB(0xeeeeee);
- _banerView.duration = 0.0f;
- _banerView.delegate = self;
- _banerView.defalutContentModel = UIViewContentModeScaleAspectFit;
- }
- return _banerView;
- }
- - (UIPageControl*)pageControl {
- if (!_pageControl) {
- _pageControl = [[UIPageControl alloc]init];
- _pageControl.currentPage = 0;
- _pageControl.hidesForSinglePage = YES;
- _pageControl.pageIndicatorTintColor = [UIColorFromRGB(0xaaaaaa) colorWithAlphaComponent:0.3];
- _pageControl.currentPageIndicatorTintColor = [UIColorFromRGB(0xaaaaaa) colorWithAlphaComponent:0.7];
- }
- return _pageControl;
- }
- - (UIButton *)goToDetailBtn{
- if (_goToDetailBtn == nil) {
- _goToDetailBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_goToDetailBtn setTitle:@"商品\n详情" forState:UIControlStateNormal];
- [_goToDetailBtn setTitleColor:UIColorFromRGB(0x333333) forState:UIControlStateNormal];
- _goToDetailBtn.titleLabel.font = [UIFont systemFontOfSize:10];
- _goToDetailBtn.titleLabel.numberOfLines = 2;
- _goToDetailBtn.backgroundColor = [UIColorFromRGB(0x000000) colorWithAlphaComponent:0.1];
- _goToDetailBtn.layer.cornerRadius = 20.0f;
- _goToDetailBtn.layer.masksToBounds = YES;
- }
-
- return _goToDetailBtn;
- }
- #pragma mark - Helper
- + (CGFloat)height {
- return UISCREENWIDTH;
- }
- @end
|