帮助页

1. .h

@interface TCHelpPageManager : NSObject

+ (instancetype)manager;

/** 

 *      社区帮助页

 */

- (void)showCommunityHelpPageWithCompleted:(TCCompleteBlock)complete;



@end


2. .m

#define CheckHasOpend( t )  if (HasOpendHelpPage( t )) {if (self.currentCompleteBlock) {self.currentCompleteBlock(self.currentHelpPage);}return;}


@interface TCHelpPageManager ()


@property (nonatomic, assign) TCHelpPageType currentHelpPage;


@property (nonatomic, copy) TCCompleteBlock currentCompleteBlock;


@end


static TCHelpPageManager *manager = nil;


@implementation TCHelpPageManager



/** *  判断 某个帮助页是否展示过 */

CG_INLINE BOOL HasOpendHelpPage(TCHelpPageType type) {

    return [TCHelpPageManager hasOpendHelpPageWithHelpPageType:type];

};


/** *  改变 某个帮助页的打开状态为TRUE */

CG_INLINE BOOL InsertHelpPage(TCHelpPageType type) {

    return [TCHelpPageManager insertOpendPage:type];

};


+ (instancetype)manager

{

    static dispatch_once_t once;

    dispatch_once(&once, ^{

        manager = [[self alloc] init];

    });

    return manager;

}

/**

 服务界面队长卡帮助页

 */


/**/

- (void)showServiceCardWithCompleted:(TCCompleteBlock)complete

{

    self.currentHelpPage = TCHelpPageType_ServiceCard;

    self.currentCompleteBlock = complete;

    CheckHasOpend(TCHelpPageType_ServiceCard);

    UIView *shadeView = [self getBackShadeView];

    

    UIImageView *topImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Captain_card_online"]];

    [shadeView addSubview:topImageView];

    [topImageView mas_makeConstraints:^(MASConstraintMaker *make) {

        make.right.equalTo(shadeView.mas_right).offset(-TCWidth(30));

        make.top.equalTo(shadeView.mas_top).offset(TCAdHeight(218));

        make.width.mas_equalTo(TCWidth(270));

        make.height.mas_equalTo(TCHeight(184));

    }];

    

    UIImageView *bottomImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"i_know_btn"]];

    [shadeView addSubview:bottomImageView];

    bottomImageView.userInteractionEnabled = YES;

    [bottomImageView mas_makeConstraints:^(MASConstraintMaker *make) {

        make.right.equalTo(shadeView.mas_right).offset(-TCWidth(71));

        make.top.equalTo(topImageView.mas_bottom).offset(TCHeight(73));

        make.width.mas_equalTo(TCWidth(115));

        make.height.mas_equalTo(TCHeight(37));

    }];

    

    

    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(shadeViewAction:)];

    [bottomImageView addGestureRecognizer:tap];

 

}

/**     [私有方法]

 *  Action Deal

 */

- (void)shadeViewAction:(UITapGestureRecognizer *)ges

{

    InsertHelpPage(self.currentHelpPage);

    

    [ges.view.superview removeFromSuperview];

    

    if (self.currentCompleteBlock) {

        self.currentCompleteBlock(self.currentHelpPage);

    }

}


/**     [私有方法]

 *  @param  complete : 统一注册complete

 */

- (UIView *)getBackShadeView

{

    

    UIView *shadeView = [[UIView allocinitWithFrame:[UIScreen mainScreen].bounds];

    shadeView.backgroundColor = [[UIColor blackColorcolorWithAlphaComponent:0.6];

    shadeView.userInteractionEnabled = YES;

//    [shadeView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(shadeViewAction:)]];

    [[TCToolBaseClass getRootViewaddSubview:shadeView];

    return shadeView;

}

/**     [ 私有方法 ]

 *  判断 某个帮助页是否展示过

 */

+ (BOOL)hasOpendHelpPageWithHelpPageType:(TCHelpPageType)type

{

    NSMutableArray *opendPages = [NSMutableArray arrayWithArray:[self getOpendHelpPage]];

    return [opendPages containsObject:[NSString stringWithFormat:@"%d", type]];

}


/**     [私有方法]

 *  改变 某个帮助页的打开状态为TRUE

 */

+ (BOOL)insertOpendPage:(TCHelpPageType)type

{

    NSMutableArray *opendPages = [NSMutableArray arrayWithArray:[self getOpendHelpPage]];

    [opendPages addObject:[NSString stringWithFormat:@"%d", type]];

    [[NSUserDefaults standardUserDefaults] setObject:opendPages forKey:kOpendHelpPages];

    return [[NSUserDefaults standardUserDefaults] synchronize];

}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值