Skip to content

Commit 7a79f61

Browse files
committed
Optimize the visual effects and interactive experience of the settings interface
- Add blur and translucent background effects to the settings interface - Adjust the modal display style of iOS 15 and above systems to support iPad - Add a top processing bar and display modes adapted to different devices - Update the version number to 2.0-5 - Optimize cell style and background transparency
1 parent 7d221c6 commit 7a79f61

File tree

4 files changed

+74
-27
lines changed

4 files changed

+74
-27
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.theos
2+
packages
3+
.DS_Store

DYYY.xm

+36-12
Original file line numberDiff line numberDiff line change
@@ -343,28 +343,52 @@
343343
UIViewController *settingVC = [[NSClassFromString(@"DYYYSettingViewController") alloc] init];
344344

345345
if (settingVC) {
346-
settingVC.modalPresentationStyle = UIModalPresentationFullScreen;
347-
348-
UIButton *closeButton = [UIButton buttonWithType:UIButtonTypeSystem];
349-
[closeButton setTitle:@"关闭" forState:UIControlStateNormal];
350-
closeButton.translatesAutoresizingMaskIntoConstraints = NO;
346+
if (@available(iOS 15.0, *)) {
347+
if (UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) {
348+
settingVC.modalPresentationStyle = UIModalPresentationFormSheet;
349+
settingVC.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
350+
settingVC.preferredContentSize = CGSizeMake(540, 620);
351+
} else {
352+
settingVC.modalPresentationStyle = UIModalPresentationPageSheet;
353+
}
354+
} else {
355+
settingVC.modalPresentationStyle = UIModalPresentationFullScreen;
356+
357+
UIButton *closeButton = [UIButton buttonWithType:UIButtonTypeSystem];
358+
[closeButton setTitle:@"关闭" forState:UIControlStateNormal];
359+
closeButton.translatesAutoresizingMaskIntoConstraints = NO;
360+
361+
[settingVC.view addSubview:closeButton];
362+
363+
[NSLayoutConstraint activateConstraints:@[
364+
[closeButton.trailingAnchor constraintEqualToAnchor:settingVC.view.trailingAnchor constant:-10],
365+
[closeButton.topAnchor constraintEqualToAnchor:settingVC.view.topAnchor constant:40],
366+
[closeButton.widthAnchor constraintEqualToConstant:80],
367+
[closeButton.heightAnchor constraintEqualToConstant:40]
368+
]];
369+
370+
[closeButton addTarget:self action:@selector(closeSettings:) forControlEvents:UIControlEventTouchUpInside];
371+
}
351372

352-
[settingVC.view addSubview:closeButton];
373+
UIView *handleBar = [[UIView alloc] init];
374+
handleBar.backgroundColor = [UIColor whiteColor];
375+
handleBar.layer.cornerRadius = 2.5;
376+
handleBar.translatesAutoresizingMaskIntoConstraints = NO;
377+
[settingVC.view addSubview:handleBar];
353378

354379
[NSLayoutConstraint activateConstraints:@[
355-
[closeButton.trailingAnchor constraintEqualToAnchor:settingVC.view.trailingAnchor constant:-10],
356-
[closeButton.topAnchor constraintEqualToAnchor:settingVC.view.topAnchor constant:40],
357-
[closeButton.widthAnchor constraintEqualToConstant:80],
358-
[closeButton.heightAnchor constraintEqualToConstant:40]
380+
[handleBar.centerXAnchor constraintEqualToAnchor:settingVC.view.centerXAnchor],
381+
[handleBar.topAnchor constraintEqualToAnchor:settingVC.view.topAnchor constant:8],
382+
[handleBar.widthAnchor constraintEqualToConstant:40],
383+
[handleBar.heightAnchor constraintEqualToConstant:5]
359384
]];
360385

361-
[closeButton addTarget:self action:@selector(closeSettings:) forControlEvents:UIControlEventTouchUpInside];
362-
363386
[rootViewController presentViewController:settingVC animated:YES completion:nil];
364387
}
365388
}
366389
}
367390
}
391+
368392
%new
369393
- (void)closeSettings:(UIButton *)button {
370394
[button.superview.window.rootViewController dismissViewControllerAnimated:YES completion:nil];

DYYYSettingViewController.m

+34-14
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ @interface DYYYSettingViewController () <UITableViewDelegate, UITableViewDataSou
4242
@property (nonatomic, strong) UILabel *footerLabel;
4343
@property (nonatomic, strong) NSMutableArray<NSString *> *sectionTitles;
4444
@property (nonatomic, strong) NSMutableSet *expandedSections;
45+
@property (nonatomic, strong) UIVisualEffectView *blurEffectView;
46+
@property (nonatomic, strong) UIVisualEffectView *vibrancyEffectView;
4547

4648
@end
4749

@@ -53,6 +55,7 @@ - (void)viewDidLoad {
5355
self.title = @"DYYY设置";
5456
self.expandedSections = [NSMutableSet set];
5557
[self setupAppearance];
58+
[self setupBlurEffect];
5659
[self setupTableView];
5760
[self setupSettingItems];
5861
[self setupSectionTitles];
@@ -61,19 +64,37 @@ - (void)viewDidLoad {
6164
}
6265

6366
- (void)setupAppearance {
64-
self.view.backgroundColor = [UIColor blackColor];
65-
self.navigationController.navigationBar.barTintColor = [UIColor blackColor];
67+
self.navigationController.navigationBar.barTintColor = [UIColor clearColor];
6668
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
6769
self.navigationController.navigationBar.largeTitleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor]};
6870
self.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeAlways;
6971
self.navigationController.navigationBar.prefersLargeTitles = YES;
7072
}
7173

74+
- (void)setupBlurEffect {
75+
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
76+
self.blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
77+
self.blurEffectView.frame = self.view.bounds;
78+
self.blurEffectView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
79+
[self.view addSubview:self.blurEffectView];
80+
81+
UIVibrancyEffect *vibrancyEffect = [UIVibrancyEffect effectForBlurEffect:blurEffect];
82+
self.vibrancyEffectView = [[UIVisualEffectView alloc] initWithEffect:vibrancyEffect];
83+
self.vibrancyEffectView.frame = self.blurEffectView.bounds;
84+
self.vibrancyEffectView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
85+
[self.blurEffectView.contentView addSubview:self.vibrancyEffectView];
86+
87+
UIView *overlayView = [[UIView alloc] initWithFrame:self.view.bounds];
88+
overlayView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.3];
89+
overlayView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
90+
[self.view addSubview:overlayView];
91+
}
92+
7293
- (void)setupTableView {
7394
self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleInsetGrouped];
7495
self.tableView.delegate = self;
7596
self.tableView.dataSource = self;
76-
self.tableView.backgroundColor = [UIColor blackColor];
97+
self.tableView.backgroundColor = [UIColor clearColor];
7798
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
7899
self.tableView.contentInset = UIEdgeInsetsMake(20, 0, 0, 0);
79100
self.tableView.sectionHeaderTopPadding = 0;
@@ -141,7 +162,7 @@ - (void)setupSectionTitles {
141162

142163
- (void)setupFooterLabel {
143164
self.footerLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 50)];
144-
self.footerLabel.text = [NSString stringWithFormat:@"Developer By @huamidev\nVersion: %@ (%@)", @"2.0-4", @"250307"];
165+
self.footerLabel.text = [NSString stringWithFormat:@"Developer By @huamidev\nVersion: %@ (%@)", @"2.0-5", @"250308"];
145166
self.footerLabel.textAlignment = NSTextAlignmentCenter;
146167
self.footerLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
147168
self.footerLabel.textColor = [UIColor colorWithRed:173/255.0 green:216/255.0 blue:230/255.0 alpha:1.0];
@@ -257,18 +278,17 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
257278

258279
cell.textLabel.text = item.title;
259280
cell.textLabel.textColor = [UIColor whiteColor];
260-
cell.backgroundColor = [UIColor colorWithRed:28/255.0 green:28/255.0 blue:29/255.0 alpha:1.0];
281+
cell.backgroundColor = [UIColor colorWithWhite:1 alpha:0.1];
282+
283+
cell.backgroundView = nil;
261284

262285
if (indexPath.row == [self.settingSections[indexPath.section] count] - 1) {
263-
UIView *bgView = [[UIView alloc] initWithFrame:cell.bounds];
264-
bgView.backgroundColor = cell.backgroundColor;
265-
cell.backgroundView = bgView;
266-
267-
cell.backgroundView.layer.cornerRadius = 10;
268-
cell.backgroundView.layer.maskedCorners = kCALayerMinXMaxYCorner | kCALayerMaxXMaxYCorner;
269-
cell.backgroundView.clipsToBounds = YES;
286+
cell.layer.cornerRadius = 10;
287+
cell.layer.maskedCorners = kCALayerMinXMaxYCorner | kCALayerMaxXMaxYCorner;
288+
cell.layer.masksToBounds = YES;
270289
} else {
271-
cell.backgroundView = nil;
290+
cell.layer.cornerRadius = 0;
291+
cell.layer.maskedCorners = 0;
272292
}
273293

274294
if (item.type == DYYYSettingItemTypeSwitch) {
@@ -286,7 +306,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
286306
attributes:@{NSForegroundColorAttributeName: [UIColor lightGrayColor]}];
287307
textField.text = [[NSUserDefaults standardUserDefaults] objectForKey:item.key];
288308
textField.textAlignment = NSTextAlignmentRight;
289-
textField.backgroundColor = [UIColor darkGrayColor];
309+
textField.backgroundColor = [UIColor colorWithWhite:1 alpha:0.1];
290310
textField.textColor = [UIColor whiteColor];
291311

292312
[textField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingDidEnd];

control

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: com.huami.dyyy
22
Name: DYYY
3-
Version: 2.0-4
3+
Version: 2.0-5
44
Description: 仅供学习交流,请在 24 小时内自觉删除。
55
Homepage: https://github.com/huami1314/DYYY
66
Section: Tweaks

0 commit comments

Comments
 (0)