Skip to content

Commit a19d719

Browse files
authored
Merge pull request #1382 from iiHorizon/master
support dark mode
2 parents 700c982 + 7a087f9 commit a19d719

File tree

5 files changed

+62
-10
lines changed

5 files changed

+62
-10
lines changed

TZImagePickerController/TZImagePickerController/TZAssetCell.m

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,11 @@ - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr
408408
- (void)setModel:(TZAlbumModel *)model {
409409
_model = model;
410410

411-
NSMutableAttributedString *nameString = [[NSMutableAttributedString alloc] initWithString:model.name attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16],NSForegroundColorAttributeName:[UIColor blackColor]}];
411+
UIColor *nameColor = UIColor.blackColor;
412+
if (@available(iOS 13.0, *)) {
413+
nameColor = UIColor.labelColor;
414+
}
415+
NSMutableAttributedString *nameString = [[NSMutableAttributedString alloc] initWithString:model.name attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16],NSForegroundColorAttributeName:nameColor}];
412416
NSAttributedString *countString = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@" (%zd)",model.count] attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16],NSForegroundColorAttributeName:[UIColor lightGrayColor]}];
413417
[nameString appendAttributedString:countString];
414418
self.titleLabel.attributedText = nameString;
@@ -461,7 +465,11 @@ - (UILabel *)titleLabel {
461465
if (_titleLabel == nil) {
462466
UILabel *titleLabel = [[UILabel alloc] init];
463467
titleLabel.font = [UIFont boldSystemFontOfSize:17];
464-
titleLabel.textColor = [UIColor blackColor];
468+
if (@available(iOS 13.0, *)) {
469+
titleLabel.textColor = UIColor.labelColor;
470+
} else {
471+
titleLabel.textColor = [UIColor blackColor];
472+
}
465473
titleLabel.textAlignment = NSTextAlignmentLeft;
466474
[self.contentView addSubview:titleLabel];
467475
_titleLabel = titleLabel;

TZImagePickerController/TZImagePickerController/TZImagePickerController.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,11 @@ - (void)configTableView {
777777
if (!self->_tableView) {
778778
self->_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
779779
self->_tableView.rowHeight = 70;
780-
self->_tableView.backgroundColor = [UIColor whiteColor];
780+
if (@available(iOS 13.0, *)) {
781+
self->_tableView.backgroundColor = [UIColor tertiarySystemBackgroundColor];
782+
} else {
783+
self->_tableView.backgroundColor = [UIColor whiteColor];
784+
}
781785
self->_tableView.tableFooterView = [[UIView alloc] init];
782786
self->_tableView.dataSource = self;
783787
self->_tableView.delegate = self;
@@ -847,6 +851,10 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
847851

848852
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
849853
TZAlbumCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TZAlbumCell"];
854+
if (@available(iOS 13.0, *)) {
855+
cell.backgroundColor = UIColor.tertiarySystemBackgroundColor;
856+
} else {
857+
}
850858
TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
851859
cell.albumCellDidLayoutSubviewsBlock = imagePickerVc.albumCellDidLayoutSubviewsBlock;
852860
cell.albumCellDidSetModelBlock = imagePickerVc.albumCellDidSetModelBlock;

TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,11 @@ - (void)configCollectionView {
166166
if (!_collectionView) {
167167
_layout = [[UICollectionViewFlowLayout alloc] init];
168168
_collectionView = [[TZCollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:_layout];
169-
_collectionView.backgroundColor = [UIColor whiteColor];
169+
if (@available(iOS 13.0, *)) {
170+
_collectionView.backgroundColor = UIColor.tertiarySystemBackgroundColor;
171+
} else {
172+
_collectionView.backgroundColor = [UIColor whiteColor];
173+
}
170174
_collectionView.dataSource = self;
171175
_collectionView.delegate = self;
172176
_collectionView.alwaysBounceHorizontal = NO;
@@ -177,6 +181,7 @@ - (void)configCollectionView {
177181
} else {
178182
[_collectionView reloadData];
179183
}
184+
180185

181186
if (_showTakePhotoBtn) {
182187
_collectionView.contentSize = CGSizeMake(self.view.tz_width, ((_model.count + self.columnNumber) / self.columnNumber) * self.view.tz_width);
@@ -224,14 +229,22 @@ - (void)configBottomToolBar {
224229

225230
_bottomToolBar = [[UIView alloc] initWithFrame:CGRectZero];
226231
CGFloat rgb = 253 / 255.0;
227-
_bottomToolBar.backgroundColor = [UIColor colorWithRed:rgb green:rgb blue:rgb alpha:1.0];
232+
if (@available(iOS 13.0, *)) {
233+
_bottomToolBar.backgroundColor = UIColor.tertiarySystemBackgroundColor;
234+
} else {
235+
_bottomToolBar.backgroundColor = [UIColor colorWithRed:rgb green:rgb blue:rgb alpha:1.0];
236+
}
228237

229238
_previewButton = [UIButton buttonWithType:UIButtonTypeCustom];
230239
[_previewButton addTarget:self action:@selector(previewButtonClick) forControlEvents:UIControlEventTouchUpInside];
231240
_previewButton.titleLabel.font = [UIFont systemFontOfSize:16];
232241
[_previewButton setTitle:tzImagePickerVc.previewBtnTitleStr forState:UIControlStateNormal];
233242
[_previewButton setTitle:tzImagePickerVc.previewBtnTitleStr forState:UIControlStateDisabled];
234-
[_previewButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
243+
if (@available(iOS 13.0, *)) {
244+
[_previewButton setTitleColor:UIColor.labelColor forState:UIControlStateNormal];
245+
} else {
246+
[_previewButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
247+
}
235248
[_previewButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateDisabled];
236249
_previewButton.enabled = tzImagePickerVc.selectedModels.count;
237250

@@ -243,7 +256,11 @@ - (void)configBottomToolBar {
243256
[_originalPhotoButton setTitle:tzImagePickerVc.fullImageBtnTitleStr forState:UIControlStateNormal];
244257
[_originalPhotoButton setTitle:tzImagePickerVc.fullImageBtnTitleStr forState:UIControlStateSelected];
245258
[_originalPhotoButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
246-
[_originalPhotoButton setTitleColor:[UIColor blackColor] forState:UIControlStateSelected];
259+
if (@available(iOS 13.0, *)) {
260+
[_originalPhotoButton setTitleColor:[UIColor labelColor] forState:UIControlStateSelected];
261+
} else {
262+
[_originalPhotoButton setTitleColor:[UIColor blackColor] forState:UIControlStateSelected];
263+
}
247264
[_originalPhotoButton setImage:tzImagePickerVc.photoOriginDefImage forState:UIControlStateNormal];
248265
[_originalPhotoButton setImage:tzImagePickerVc.photoOriginSelImage forState:UIControlStateSelected];
249266
_originalPhotoButton.imageView.clipsToBounds = YES;
@@ -254,7 +271,11 @@ - (void)configBottomToolBar {
254271
_originalPhotoLabel = [[UILabel alloc] init];
255272
_originalPhotoLabel.textAlignment = NSTextAlignmentLeft;
256273
_originalPhotoLabel.font = [UIFont systemFontOfSize:16];
257-
_originalPhotoLabel.textColor = [UIColor blackColor];
274+
if (@available(iOS 13.0, *)) {
275+
_originalPhotoLabel.textColor = [UIColor labelColor];
276+
} else {
277+
_originalPhotoLabel.textColor = [UIColor blackColor];
278+
}
258279
if (_isSelectOriginalPhoto) [self getSelectedPhotoBytes];
259280
}
260281

@@ -284,7 +305,19 @@ - (void)configBottomToolBar {
284305

285306
_divideLine = [[UIView alloc] init];
286307
CGFloat rgb2 = 222 / 255.0;
287-
_divideLine.backgroundColor = [UIColor colorWithRed:rgb2 green:rgb2 blue:rgb2 alpha:1.0];
308+
if (@available(iOS 13.0, *)) {
309+
UIColor *divideLineDyColor = [UIColor colorWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * _Nonnull trainCollection) {
310+
if ([trainCollection userInterfaceStyle] == UIUserInterfaceStyleLight) {
311+
return [UIColor colorWithRed:rgb2 green:rgb2 blue:rgb2 alpha:1.0];
312+
} else {
313+
CGFloat lineDarkRgb = 100 / 255.0;
314+
return [UIColor colorWithRed:lineDarkRgb green:lineDarkRgb blue:lineDarkRgb alpha:1.0];
315+
}
316+
}];
317+
_divideLine.backgroundColor = divideLineDyColor;
318+
} else {
319+
_divideLine.backgroundColor = [UIColor colorWithRed:rgb2 green:rgb2 blue:rgb2 alpha:1.0];
320+
}
288321

289322
[_bottomToolBar addSubview:_divideLine];
290323
[_bottomToolBar addSubview:_previewButton];

TZImagePickerController/TZImagePickerController/TZVideoPlayerController.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313

1414
@property (nonatomic, strong) TZAssetModel *model;
1515

16-
@end
16+
@end
17+

TZImagePickerController/TZImagePickerController/TZVideoPlayerController.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ @interface TZVideoPlayerController () {
2727
UIStatusBarStyle _originStatusBarStyle;
2828
}
2929
@property (assign, nonatomic) BOOL needShowStatusBar;
30+
3031
// iCloud无法同步提示UI
3132
@property (nonatomic, strong) UIView *iCloudErrorView;
33+
3234
@end
3335

3436
#pragma clang diagnostic push

0 commit comments

Comments
 (0)