Skip to content
This repository has been archived by the owner on Jul 2, 2020. It is now read-only.

support tab bar and gradient layer #109

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions DKNightVersion.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
0395580A1DFB8376002AC625 /* DKAlpha.m in Sources */ = {isa = PBXBuildFile; fileRef = 039558081DFB8376002AC625 /* DKAlpha.m */; };
341009701DDCA07400CA390F /* CAShapeLayer+Night.h in Headers */ = {isa = PBXBuildFile; fileRef = 3410096E1DDCA07400CA390F /* CAShapeLayer+Night.h */; };
341009711DDCA07400CA390F /* CAShapeLayer+Night.m in Sources */ = {isa = PBXBuildFile; fileRef = 3410096F1DDCA07400CA390F /* CAShapeLayer+Night.m */; };
5FBDEF0F2067A53000B7A4C8 /* CAGradientLayer+Night.h in Headers */ = {isa = PBXBuildFile; fileRef = 5FBDEF0D2067A53000B7A4C8 /* CAGradientLayer+Night.h */; settings = {ATTRIBUTES = (Public, ); }; };
5FBDEF102067A53000B7A4C8 /* CAGradientLayer+Night.m in Sources */ = {isa = PBXBuildFile; fileRef = 5FBDEF0E2067A53000B7A4C8 /* CAGradientLayer+Night.m */; };
5FBDEF132067A90000B7A4C8 /* UITabBarItem+Night.m in Sources */ = {isa = PBXBuildFile; fileRef = 5FBDEF112067A90000B7A4C8 /* UITabBarItem+Night.m */; };
5FBDEF142067A90000B7A4C8 /* UITabBarItem+Night.h in Headers */ = {isa = PBXBuildFile; fileRef = 5FBDEF122067A90000B7A4C8 /* UITabBarItem+Night.h */; settings = {ATTRIBUTES = (Public, ); }; };
7287AB781D0437A300D544B4 /* UITextView+Keyboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 7287AB761D0437A300D544B4 /* UITextView+Keyboard.h */; };
7287AB791D0437A300D544B4 /* UITextView+Keyboard.m in Sources */ = {isa = PBXBuildFile; fileRef = 7287AB771D0437A300D544B4 /* UITextView+Keyboard.m */; };
7295D7CB1D07E2A000525182 /* UISearchBar+Keyboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 7295D7C91D07E2A000525182 /* UISearchBar+Keyboard.h */; };
Expand Down Expand Up @@ -83,6 +87,10 @@
039558081DFB8376002AC625 /* DKAlpha.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DKAlpha.m; sourceTree = "<group>"; };
3410096E1DDCA07400CA390F /* CAShapeLayer+Night.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CAShapeLayer+Night.h"; sourceTree = "<group>"; };
3410096F1DDCA07400CA390F /* CAShapeLayer+Night.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "CAShapeLayer+Night.m"; sourceTree = "<group>"; };
5FBDEF0D2067A53000B7A4C8 /* CAGradientLayer+Night.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CAGradientLayer+Night.h"; sourceTree = "<group>"; };
5FBDEF0E2067A53000B7A4C8 /* CAGradientLayer+Night.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "CAGradientLayer+Night.m"; sourceTree = "<group>"; };
5FBDEF112067A90000B7A4C8 /* UITabBarItem+Night.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UITabBarItem+Night.m"; sourceTree = "<group>"; };
5FBDEF122067A90000B7A4C8 /* UITabBarItem+Night.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UITabBarItem+Night.h"; sourceTree = "<group>"; };
7287AB761D0437A300D544B4 /* UITextView+Keyboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UITextView+Keyboard.h"; sourceTree = "<group>"; };
7287AB771D0437A300D544B4 /* UITextView+Keyboard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UITextView+Keyboard.m"; sourceTree = "<group>"; };
729323341CB9F98C009E544E /* DKNightVersion.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = DKNightVersion.framework; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -230,6 +238,8 @@
72E18B431CBA03480004EBB2 /* UIToolbar+Night.m */,
72E18B441CBA03480004EBB2 /* UIView+Night.h */,
72E18B451CBA03480004EBB2 /* UIView+Night.m */,
5FBDEF122067A90000B7A4C8 /* UITabBarItem+Night.h */,
5FBDEF112067A90000B7A4C8 /* UITabBarItem+Night.m */,
);
path = UIKit;
sourceTree = "<group>";
Expand Down Expand Up @@ -280,6 +290,8 @@
72E18B571CBA03480004EBB2 /* CALayer+Night.m */,
3410096E1DDCA07400CA390F /* CAShapeLayer+Night.h */,
3410096F1DDCA07400CA390F /* CAShapeLayer+Night.m */,
5FBDEF0D2067A53000B7A4C8 /* CAGradientLayer+Night.h */,
5FBDEF0E2067A53000B7A4C8 /* CAGradientLayer+Night.m */,
72E18B581CBA03480004EBB2 /* CoreAnimation+Night.h */,
);
path = CoreAnimation;
Expand Down Expand Up @@ -319,6 +331,8 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
5FBDEF0F2067A53000B7A4C8 /* CAGradientLayer+Night.h in Headers */,
5FBDEF142067A90000B7A4C8 /* UITabBarItem+Night.h in Headers */,
72E18B6C1CBA03480004EBB2 /* UINavigationBar+Night.h in Headers */,
72E18B7E1CBA03480004EBB2 /* UITextView+Night.h in Headers */,
72E18B821CBA03480004EBB2 /* UIView+Night.h in Headers */,
Expand Down Expand Up @@ -446,6 +460,7 @@
72E18B6D1CBA03480004EBB2 /* UINavigationBar+Night.m in Sources */,
729A5D601CBB347700E8A164 /* README.md in Sources */,
72E18B671CBA03480004EBB2 /* UIBarButtonItem+Night.m in Sources */,
5FBDEF102067A53000B7A4C8 /* CAGradientLayer+Night.m in Sources */,
72E18B851CBA03480004EBB2 /* UIButton+Night.m in Sources */,
72E18B9C1CBA03480004EBB2 /* DKColorTable.m in Sources */,
72E18B7F1CBA03480004EBB2 /* UITextView+Night.m in Sources */,
Expand All @@ -454,6 +469,7 @@
0395580A1DFB8376002AC625 /* DKAlpha.m in Sources */,
72E18B8D1CBA03480004EBB2 /* DKDeallocBlockExecutor.m in Sources */,
72E18B941CBA03480004EBB2 /* DKColor.m in Sources */,
5FBDEF132067A90000B7A4C8 /* UITabBarItem+Night.m in Sources */,
72E18B7D1CBA03480004EBB2 /* UITextField+Night.m in Sources */,
72E18B961CBA03480004EBB2 /* DKImage.m in Sources */,
72E18B831CBA03480004EBB2 /* UIView+Night.m in Sources */,
Expand Down
16 changes: 16 additions & 0 deletions DKNightVersion/CoreAnimation/CAGradientLayer+Night.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// CAGradientLayer+Night.h
// IXApp
//
// Created by Seven on 2017/12/8.
// Copyright © 2017年 IX. All rights reserved.
//

#import <QuartzCore/QuartzCore.h>
#import "NSObject+Night.h"

@interface CAGradientLayer (Night)

@property (nonatomic, strong) NSArray * dk_colors;

@end
53 changes: 53 additions & 0 deletions DKNightVersion/CoreAnimation/CAGradientLayer+Night.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// CAGradientLayer+Night.m
// IXApp
//
// Created by Seven on 2017/12/8.
// Copyright © 2017年 IX. All rights reserved.
//

#import "CAGradientLayer+Night.h"
#import "DKNightVersionManager.h"
#import <objc/runtime.h>

@interface CAGradientLayer ()

@property (nonatomic, strong) NSMutableDictionary<NSString *, id> *pickers;

@end

@implementation CAGradientLayer (Night)

- (NSArray *)dk_colors
{
return objc_getAssociatedObject(self, @selector(dk_colors));
}

- (void)setDk_colors:(NSArray *)dk_colors
{
objc_setAssociatedObject(self, @selector(dk_colors), dk_colors, OBJC_ASSOCIATION_COPY_NONATOMIC);
NSMutableArray * arr = [@[] mutableCopy];
for (int i = 0; i < dk_colors.count; i ++) {
DKColorPicker picker = dk_colors[i];
[arr addObject:(__bridge id)picker(self.dk_manager.themeVersion).CGColor];
}
self.colors = arr.copy;
[self.pickers setValue:dk_colors forKey:NSStringFromSelector(@selector(setColors:))];
}

- (void)night_updateColor {
__block NSMutableArray * colorArr = [@[] mutableCopy];
[self.pickers enumerateKeysAndObjectsUsingBlock:^(NSString * _Nonnull selector, id _Nonnull obj, BOOL * _Nonnull stop) {
if ([selector isEqualToString:NSStringFromSelector(@selector(setColors:))]) {
NSArray * dk_colors = obj;
for (int i = 0; i < dk_colors.count; i ++) {
DKColorPicker picker = dk_colors[i];
[colorArr addObject:(__bridge id)picker(self.dk_manager.themeVersion).CGColor];
}
}
}];

self.colors = colorArr.copy;
}

@end
3 changes: 3 additions & 0 deletions DKNightVersion/DKNightVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ FOUNDATION_EXPORT const unsigned char DKNightVersionVersionString[];
#import <DKNightVersion/UIView+Night.h>
#import <DKNightVersion/UIButton+Night.h>
#import <DKNightVersion/UIImageView+Night.h>
#import <DKNightVersion/UITabBarItem+Night.h>
#import <DKNightVersion/CAGradientLayer+Night.h>


#import <DKNightVersion/metamacros.h>
#import <DKNightVersion/EXTKeyPathCoding.h>
Expand Down
18 changes: 18 additions & 0 deletions DKNightVersion/UIKit/UITabBarItem+Night.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// UITabBarItem+Night.h
// IXApp
//
// Created by Seven on 2017/6/13.
// Copyright © 2017年 IX. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "NSObject+Night.h"

@interface UITabBarItem (Night)

@property (nullable, nonatomic, copy, setter = dk_setImagePicker:) DKImagePicker dk_imagePicker;

@property (nullable, nonatomic, copy, setter = dk_setSelectedImagePicker:) DKImagePicker dk_selectedImagePicker;

@end
49 changes: 49 additions & 0 deletions DKNightVersion/UIKit/UITabBarItem+Night.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//
// UITabBarItem+Night.m
// IXApp
//
// Created by Seven on 2017/6/13.
// Copyright © 2017年 IX. All rights reserved.
//

#import "UITabBarItem+Night.h"
#import "DKNightVersionManager.h"
#import <objc/runtime.h>

@interface UITabBarItem ()

@property (nonatomic, strong) NSMutableDictionary<NSString *, id> *pickers;

@end

@implementation UITabBarItem (Night)

- (DKImagePicker)dk_imagePicker
{
return objc_getAssociatedObject(self, @selector(dk_imagePicker));
}

- (DKImagePicker)dk_selectedImagePicker
{
return objc_getAssociatedObject(self, @selector(dk_selectedImagePicker));
}

- (void)dk_setImagePicker:(DKImagePicker)picker
{
objc_setAssociatedObject(self, @selector(dk_imagePicker), picker, OBJC_ASSOCIATION_COPY_NONATOMIC);
self.image = picker(self.dk_manager.themeVersion);

NSString *key = NSStringFromSelector(@selector(setImage:));
[self.pickers setValue:[picker copy] forKey:key];
}

- (void)dk_setSelectedImagePicker:(DKImagePicker)picker
{
objc_setAssociatedObject(self, @selector(dk_imagePicker), picker, OBJC_ASSOCIATION_COPY_NONATOMIC);
self.selectedImage = picker(self.dk_manager.themeVersion);

NSString *key = NSStringFromSelector(@selector(setSelectedImage:));
[self.pickers setValue:[picker copy] forKey:key];
}

@end