Files
keyboard/keyBoard/Class/Me/VC/KBNoticeVC.m

108 lines
3.6 KiB
Mathematica
Raw Normal View History

2025-11-24 20:15:41 +08:00
#import "KBNoticeVC.h"
#import <Masonry/Masonry.h>
@interface KBNoticeVC ()
///
@property (nonatomic, strong) UIView *cardView;
/// Notification Setting
@property (nonatomic, strong) UILabel *noticeTitleLabel;
///
@property (nonatomic, strong) UISwitch *noticeSwitch;
@end
@implementation KBNoticeVC
- (void)viewDidLoad {
[super viewDidLoad];
//
self.view.backgroundColor = [UIColor colorWithHex:0xF8F8F8];
//
self.kb_titleLabel.text = KBLocalized(@"Notice");
//
[self.view addSubview:self.cardView];
[self.cardView addSubview:self.noticeTitleLabel];
[self.cardView addSubview:self.noticeSwitch];
//
[self.cardView mas_makeConstraints:^(MASConstraintMaker *make) {
//
make.top.equalTo(self.view).offset(KB_NAV_TOTAL_HEIGHT + 16);
make.left.equalTo(self.view).offset(16);
make.right.equalTo(self.view).offset(-16);
make.height.mas_equalTo(64);
}];
//
[self.noticeTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.cardView).offset(20);
make.centerY.equalTo(self.cardView);
}];
//
[self.noticeSwitch mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.cardView).offset(-20);
make.centerY.equalTo(self.cardView);
}];
}
#pragma mark - Actions
///
- (void)noticeSwitchChanged:(UISwitch *)sender {
BOOL isOn = sender.isOn;
// TODO: isOn
}
#pragma mark - Lazy Load
- (UIView *)cardView {
if (!_cardView) {
_cardView = [UIView new];
_cardView.backgroundColor = [UIColor whiteColor];
_cardView.layer.cornerRadius = 16.0;
_cardView.layer.masksToBounds = NO;
// 稿
_cardView.layer.shadowColor = [UIColor colorWithWhite:0 alpha:0.06].CGColor;
_cardView.layer.shadowOpacity = 1.0;
_cardView.layer.shadowOffset = CGSizeMake(0, 4);
_cardView.layer.shadowRadius = 8.0;
}
return _cardView;
}
- (UILabel *)noticeTitleLabel {
if (!_noticeTitleLabel) {
_noticeTitleLabel = [UILabel new];
_noticeTitleLabel.textColor = [UIColor blackColor];
_noticeTitleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightSemibold];
// Localizable.strings
_noticeTitleLabel.text = KBLocalized(@"Notification Setting");
}
return _noticeTitleLabel;
}
- (UISwitch *)noticeSwitch {
if (!_noticeSwitch) {
_noticeSwitch = [[UISwitch alloc] init];
_noticeSwitch.on = YES;
//
if (@available(iOS 13.0, *)) {
_noticeSwitch.onTintColor = [UIColor systemGreenColor];
} else {
_noticeSwitch.onTintColor = [UIColor colorWithRed:76/255.0
green:217/255.0
blue:100/255.0
alpha:1.0];
}
//
[_noticeSwitch addTarget:self
action:@selector(noticeSwitchChanged:)
forControlEvents:UIControlEventValueChanged];
}
return _noticeSwitch;
}
@end