IVTNewMessageRemindViewController.m
4.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
//
// IVTNewMessageRemindViewController.m
// IVTMeLiveTwo
//
// Created by XRG on 16/8/23.
// Copyright © 2016年 QLQ. All rights reserved.
//
#import "IVTNewMessageRemindViewController.h"
@interface IVTNewMessageRemindViewController ()
{
UIImageView *bgImageView;
UILabel *messageText;
UISwitch *messageRemindSwitch;
UIButton *goSettingButton;
}
@end
@implementation IVTNewMessageRemindViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self setNavigationBar];
bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"我的--第一个背景条"]];
bgImageView.userInteractionEnabled = YES;
bgImageView.frame = CGRectMake(0, 10, kScreenWidth, 44);
[self.view addSubview:bgImageView];
messageText = [[UILabel alloc] init];
messageText.font = [UIFont IVTH3Font];
messageText.textAlignment = 1;
messageText.text = @"直播消息提醒";
messageText.textColor = [UIColor IVTMainTextColor];
[bgImageView addSubview:messageText];
[messageText mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(bgImageView).offset(5);
make.left.equalTo(bgImageView).offset(10);
make.size.mas_equalTo(CGSizeMake(120, 30));
}];
messageRemindSwitch = [[UISwitch alloc] init];
messageRemindSwitch.onTintColor = [UIColor YXColorWithHexCode:@"D31863"];
if ([self isAllowedNotification]) {
messageRemindSwitch.on = YES;
}
else{
messageRemindSwitch.on = NO;
}
// [_MessageRemindSwitch addTarget:self action:@selector(switchNotification:) forControlEvents:UIControlEventValueChanged];
[bgImageView addSubview:messageRemindSwitch];
[messageRemindSwitch mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(bgImageView).offset(5);
make.right.equalTo(bgImageView).offset(-20);
}];
goSettingButton = [UIButton buttonWithType:UIButtonTypeCustom];
goSettingButton.titleLabel.font = [UIFont systemFontOfSize:13];
[goSettingButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
[goSettingButton setTitle:@"请在iPhone的“设置”-“通知”中进行修改。" forState:UIControlStateNormal];
[goSettingButton addTarget:self action:@selector(doSettingButton) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:goSettingButton];
[goSettingButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(bgImageView.mas_bottom).offset(5);
make.left.equalTo(bgImageView.mas_left).offset(5);
make.right.equalTo(bgImageView.mas_right).offset(-10);
make.height.mas_equalTo(40);
}];
}
- (void)setNavigationBar{
self.navigationItem.title = @"新消息提醒";
}
- (void)doSettingButton{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
}
//- (void)switchNotification:(id)sender
//{
// UISwitch *switchButton = (UISwitch*)sender;
// BOOL isButtonOn = [switchButton isOn];
// if (isButtonOn) {
// [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
//// NSURL*url=[NSURL URLWithString:@"prefs:root=NOTIFICATIONS_ID"];
//// [[UIApplication sharedApplication] openURL:url];
// }else {
// [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
// }
//}
- (BOOL)isAllowedNotification {
UIUserNotificationSettings *setting = [[UIApplication sharedApplication] currentUserNotificationSettings];
if (UIUserNotificationTypeNone != setting.types) {
return YES;
}
return NO;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end