123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- //
- // NewDynamicListShieldView.m
- // 乐销
- //
- // Created by liuhuiping on 2017/10/28.
- // Copyright © 2017年 ping. All rights reserved.
- //
- #import "NewDynamicListShieldView.h"
- @implementation NewDynamicListShieldView
- #pragma mark lazy
- - (UIScrollView *)shareScrollView{
- if (_shareScrollView == nil) {
- _shareScrollView = [UIScrollView new];
- _shareScrollView.frame = CGRectMake(W(0), W(0), SCREEN_WIDTH, W(123));
- _shareScrollView.contentSize = CGSizeMake(0, 0);
- _shareScrollView.backgroundColor = [UIColor whiteColor];
- _shareScrollView.showsHorizontalScrollIndicator = false;
- _shareScrollView.showsVerticalScrollIndicator = false;
- }
- return _shareScrollView;
- }
- - (DynamicListShieldHeaderView *)headerView {
- if (!_headerView) {
- _headerView = [DynamicListShieldHeaderView new];
- _headerView.frame = CGRectMake(W(0), W(0), SCREEN_WIDTH, self.headerView.height);
- _headerView.bottom = SCREEN_HEIGHT;
- [_headerView.control addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
-
- }
- return _headerView;
- }
- - (NSArray *)shareAryDatas{
- if (!_shareAryDatas) {
- _shareAryDatas = @[[ModelBtn modelWithTitle:@"微信好友" imageName:@"wd_wx" highImageName:@"wd_wx" tag:0],[ModelBtn modelWithTitle:@"朋友圈" imageName:@"wd_pyq" highImageName:@"wd_pyq" tag:1]];
- }
- return _shareAryDatas;
-
- }
- #pragma mark 初始化
- - (instancetype)initWithFrame:(CGRect)frame{
- self = [super initWithFrame:frame];
- if (self) {
- [self addSubView];
- }
- return self;
- }
- //添加subview
- - (void)addSubView{
- self.backgroundColor = COLOR_BLACK_ALPHA_PER60;
- self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
- [self addSubview:self.shareScrollView];
- [self addSubview:self.headerView];
- [self addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
- }
- - (void)resetWithModel:(id)model{
- self.headerView.leftBottom =XY(0,SCREEN_HEIGHT);
- WEAKSELF
- if (isAry(self.shareAryDatas)) {
- self.shareScrollView.bottom = [self addLineFrame:CGRectMake(W(15), self.headerView.top, SCREEN_WIDTH-W(30), 1)];
- CGFloat left = 0;
- for (ModelBtn * model in self.shareAryDatas) {
- ShieldView * view = [ShieldView new];
- view.blockModel = ^(ModelBtn *modelBtn) {
- if (weakSelf.blockSelectBtnModel) {
- weakSelf.blockSelectBtnModel(modelBtn);
- [weakSelf removeFromSuperview];
- }
- };
- [view resetViewWithModel:model];
-
- view.left = left;
- left = view.right;
-
- [self.shareScrollView addSubview:view];
- self.shareScrollView.contentSize = CGSizeMake(left, 0);
- }
- }
-
- }
- #pragma mark btnClick
- - (void)btnClick:(UIButton *)sender{
- [self removeFromSuperview];
- }
- @end
- @implementation ShieldView
- #pragma mark 懒加载
- - (UIImageView *)imgView{
- if (_imgView == nil) {
- _imgView = [UIImageView new];
- _imgView.widthHeight = XY(W(60),W(60));
- }
- return _imgView;
- }
- - (UILabel *)labelName{
- if (_labelName == nil) {
- _labelName = [UILabel new];
- [GlobalMethod setLabel:_labelName widthLimit:0 numLines:0 fontNum:F(14) textColor:COLOR_LABEL text:@""];
- }
- return _labelName;
- }
- #pragma mark 初始化
- - (instancetype)initWithFrame:(CGRect)frame{
- self = [super initWithFrame:frame];
- if (self) {
- self.backgroundColor = [UIColor whiteColor];
- self.width = SCREEN_WIDTH;
- [self addSubView];
- }
- return self;
- }
- //添加subview
- - (void)addSubView{
- [self addSubview:self.imgView];
- [self addSubview:self.labelName];
- [self addTarget:self action:@selector(btnClick:) forControlEvents:(UIControlEventTouchUpInside)];
- //初始化页面
- [self resetViewWithModel:nil];
- }
- #pragma mark 刷新view
- - (void)resetViewWithModel:(ModelBtn *)model{
- self.model = model;
- [self removeSubViewWithTag:TAG_LINE];//移除线
- //刷新view
- self.imgView.image = [UIImage imageNamed:model.imageName];
- self.imgView.leftTop = XY(W(20),W(20));
-
- [self.labelName fitTitle:model.title variable:0];
- self.labelName.centerXTop = XY(self.imgView.centerX,self.imgView.bottom+W(10));
- self.labelName.textColor = model.color?model.color:COLOR_DETAIL;
-
- self.width = self.imgView.right;
- self.height = self.labelName.bottom+W(20);
- }
- #pragma mark click
- - (void)btnClick:(UIButton *)sender {
- if (self.blockModel) {
- self.blockModel(self.model);
- }
- }
- @end
- @implementation DynamicListShieldHeaderView
- #pragma mark 懒加载
- - (UIImageView *)imgView{
- if (_imgView == nil) {
- _imgView = [UIImageView new];
- _imgView.image = [UIImage imageNamed:@"tx_gb"];
- _imgView.widthHeight = XY(W(15),W(15));
- }
- return _imgView;
- }
- - (UIControl *)control{
- if (_control == nil) {
- _control = [UIControl new];
- _control.tag = 1;
- _control.backgroundColor = [UIColor clearColor];
- _control.widthHeight = XY(SCREEN_WIDTH,W(0));
- }
- return _control;
- }
- #pragma mark 初始化
- - (instancetype)initWithFrame:(CGRect)frame{
- self = [super initWithFrame:frame];
- if (self) {
- self.backgroundColor = [UIColor whiteColor];
- [self addSubView];
- }
- return self;
- }
- //添加subview
- - (void)addSubView{
- [self addSubview:self.imgView];
- [self addSubview:self.control];
- [self resetView];
- }
- #pragma mark 刷新view
- - (void)resetView{
- [self removeSubViewWithTag:TAG_LINE];//移除线
- //刷新view
- self.imgView.centerXTop = XY(SCREEN_WIDTH/2,W(15));
-
- self.height = [self addLineFrame:CGRectMake(W(0), self.imgView.bottom+W(15), SCREEN_WIDTH, 1)];
-
- self.control.widthHeight = XY(SCREEN_WIDTH, self.height);
- self.control.leftTop = XY(W(0),W(0));
- }
- @end
|