口袋优选

PGIndexBannerSubiew.m 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //
  2. // PGIndexBannerSubiew.m
  3. // NewPagedFlowViewDemo
  4. //
  5. // Created by Mars on 16/6/18.
  6. // Copyright © 2016年 Mars. All rights reserved.
  7. // Designed By PageGuo,
  8. // QQ:799573715
  9. // github:https://github.com/PageGuo/NewPagedFlowView
  10. #import "PGIndexBannerSubiew.h"
  11. @implementation PGIndexBannerSubiew
  12. - (instancetype)initWithFrame:(CGRect)frame {
  13. self = [super initWithFrame:frame];
  14. if (self) {
  15. [self addSubview:self.mainImageView];
  16. [self addSubview:self.coverView];
  17. UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleCellTapAction:)];
  18. [self addGestureRecognizer:singleTap];
  19. }
  20. return self;
  21. }
  22. - (void)singleCellTapAction:(UIGestureRecognizer *)gesture {
  23. if (self.didSelectCellBlock) {
  24. self.didSelectCellBlock(self.tag, self);
  25. }
  26. }
  27. - (void)setSubviewsWithSuperViewBounds:(CGRect)superViewBounds {
  28. if (CGRectEqualToRect(self.mainImageView.frame, superViewBounds)) {
  29. return;
  30. }
  31. self.mainImageView.frame = superViewBounds;
  32. self.coverView.frame = superViewBounds;
  33. }
  34. - (UIImageView *)mainImageView {
  35. if (_mainImageView == nil) {
  36. _mainImageView = [[UIImageView alloc] init];
  37. _mainImageView.userInteractionEnabled = YES;
  38. }
  39. return _mainImageView;
  40. }
  41. - (UIView *)coverView {
  42. if (_coverView == nil) {
  43. _coverView = [[UIView alloc] init];
  44. _coverView.backgroundColor = [UIColor blackColor];
  45. }
  46. return _coverView;
  47. }
  48. @end