You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
3.2 KiB
86 lines
3.2 KiB
4 years ago
|
//
|
||
|
// TFPushSetTableViewCell.m
|
||
|
// WXReader
|
||
|
//
|
||
|
// Created by 谢腾飞 on 2020/12/2.
|
||
|
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||
|
//
|
||
|
|
||
|
#import "TFPushSetTableViewCell.h"
|
||
|
|
||
|
@interface TFPushSetTableViewCell ()
|
||
|
{
|
||
|
UIButton *openButton;
|
||
|
UIImageView *connerImageView;
|
||
|
}
|
||
|
@end
|
||
|
|
||
|
@implementation TFPushSetTableViewCell
|
||
|
|
||
|
- (void)createSubviews
|
||
|
{
|
||
|
[super createSubviews];
|
||
|
|
||
|
connerImageView = [[UIImageView alloc] init];
|
||
|
connerImageView.image = [UIImage imageNamed:@"public_more"];
|
||
|
[self.contentView addSubview:connerImageView];
|
||
|
|
||
|
[connerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kMargin);
|
||
|
make.centerY.mas_equalTo(self.contentView.mas_centerY);
|
||
|
make.width.height.mas_equalTo(10);
|
||
|
}];
|
||
|
|
||
|
openButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||
|
[openButton setTitle:TFLocalizedString(@"点击开启") forState:UIControlStateNormal];
|
||
|
[openButton setTitleColor:kBlackColor forState:UIControlStateNormal];
|
||
|
[openButton.titleLabel setFont:kFont12];
|
||
|
[openButton addTarget:self action:@selector(permissionsClick) forControlEvents:UIControlEventTouchUpInside];
|
||
|
[self.contentView addSubview:openButton];
|
||
|
|
||
|
[openButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.right.mas_equalTo(connerImageView.mas_left).with.offset(- kHalfMargin);
|
||
|
make.centerY.mas_equalTo(self.contentView.mas_centerY);
|
||
|
make.width.mas_equalTo(60);
|
||
|
make.height.mas_equalTo(self.leftTitleLabel.mas_height);
|
||
|
}];
|
||
|
}
|
||
|
|
||
|
- (void)setAllowedPush:(BOOL)allowedPush
|
||
|
{
|
||
|
_allowedPush = allowedPush;
|
||
|
|
||
|
if (allowedPush) {
|
||
|
[openButton setTitle:TFLocalizedString(@"已开启") forState:UIControlStateNormal];
|
||
|
CGFloat width = [TFViewHelper getDynamicWidthWithLabelFont:kFont12 labelHeight:30.0 labelText:TFLocalizedString(@"已开启") maxWidth:SCREEN_WIDTH / 2.0];
|
||
|
[openButton mas_updateConstraints:^(MASConstraintMaker *make) {
|
||
|
make.width.mas_equalTo(width);
|
||
|
}];
|
||
|
[openButton setTitleColor:kGrayTextColor forState:UIControlStateNormal];
|
||
|
[connerImageView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||
|
make.right.mas_equalTo(self.contentView.mas_right).with.offset(CGFLOAT_MIN);
|
||
|
make.width.mas_equalTo(CGFLOAT_MIN);
|
||
|
}];
|
||
|
} else {
|
||
|
[openButton setTitle:TFLocalizedString(@"点击开启") forState:UIControlStateNormal];
|
||
|
CGFloat width = [TFViewHelper getDynamicWidthWithLabelFont:kFont12 labelHeight:30.0 labelText:TFLocalizedString(@"点击开启") maxWidth:SCREEN_WIDTH / 2.0];
|
||
|
[openButton mas_updateConstraints:^(MASConstraintMaker *make) {
|
||
|
make.width.mas_equalTo(width);
|
||
|
}];
|
||
|
[openButton setTitleColor:kBlackColor forState:UIControlStateNormal];
|
||
|
[connerImageView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||
|
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kMargin);
|
||
|
make.width.mas_equalTo(10);
|
||
|
}];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
- (void)permissionsClick
|
||
|
{
|
||
|
if (!_allowedPush) {
|
||
|
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@end
|