-
UIColor
support -
UIImage
andUIImageView
support - Hight performance
- Providing UIKit categoty
- Providing CoreAnimation categoty
- Easily integrate to iOS App
- Based on
objc/runtime
- Generate by ruby script
- Default DKColorPicker
- Support NSAttributedString
CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like DKNightVersion in your projects. See the Get Started section for more details.
Run following script in termianl
$ pod update
Add this line to your podfile
pod "DKNightVersion", "~> 1.2"
Just add one line of code in your precompiled header, or import it where you need.
#import "DKNightVersion.h"
DKNightVersion is based on picker, such as dk_backgroundColorPicker
dk_separatorColorPicker
and etc. Assign the night mode color picker you want to the UIKit
component like this:
self.tableView.dk_backgroundColorPicker = DKColorWithRGB(0xffffff, 0x343434);
self.tableView.dk_separatorColorPicker = DKColorWithRGB(0xaaaaaa, 0x313131);
navigationLabel.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
DKNightVersion providing new API
to support image switching.
imageView.dk_imagePicker = DKImageWithNames(@"normal1", @"night1");
DKColor
provides - pickerWithNormalColor:nightColor:
to create DKColorPicker
.
DKColorPicker DKColorWithRGB(NSUInteger normal, NSUInteger night);
DKColorPicker DKColorWithColors(UIColor *normalColor, UIColor *nightColor);
DKColor
also provides a cluster of convienient API
like UIColor
which returns DKColorPicker
block, these block return the same color when switch to night mode or switch back.
+ (DKColorPicker)pickerWithUIColor:(UIColor *)color;
+ (DKColorPicker)colorWithWhite:(CGFloat)white alpha:(CGFloat)alpha;
+ (DKColorPicker)colorWithHue:(CGFloat)hue saturation:(CGFloat)saturation brightness:(CGFloat)brightness alpha:(CGFloat)alpha;
+ (DKColorPicker)colorWithRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha;
+ (DKColorPicker)colorWithCGColor:(CGColorRef)cgColor;
+ (DKColorPicker)colorWithPatternImage:(UIImage *)image;
#if __has_include(<CoreImage/CoreImage.h>)
+ (DKColorPicker)colorWithCIColor:(CIColor *)ciColor NS_AVAILABLE_IOS(5_0);
#endif
+ (DKColorPicker)blackColor;
+ (DKColorPicker)darkGrayColor;
+ (DKColorPicker)lightGrayColor;
+ (DKColorPicker)whiteColor;
+ (DKColorPicker)grayColor;
+ (DKColorPicker)redColor;
+ (DKColorPicker)greenColor;
+ (DKColorPicker)blueColor;
+ (DKColorPicker)cyanColor;
+ (DKColorPicker)yellowColor;
+ (DKColorPicker)magentaColor;
+ (DKColorPicker)orangeColor;
+ (DKColorPicker)purpleColor;
+ (DKColorPicker)brownColor;
+ (DKColorPicker)clearColor;
If you have the same DKColorPicker
for different UIKit components, use DKColorTable
to save them and take out of them with DKPickerFromTable(NSString *key)
function.
DKColorTable provides three methods and a C function to manipulate color table and get picker from it.
DKPickerFromTable(NSString *key)
+ (void)addPicker:(DKColorPicker)picker withKey:(NSString *)key;
+ (DKColorPicker)removePickerWithKey:(NSString *)key;
+ (DKColorPicker)pickerWithKey:(NSString *)key;
DKImage is similar with DKColor which contains methods to generate DKImagePicker
DKImagePicker DKImageWithNames(NSString *normal, NSString *night);
DKImagePicker DKImageWithImages(UIImage *normal, UIImage *night);
Use DKNightVersionManager
sets the theme.
[DKNightVersionManager nightFalling];
If you'd like to switch back to normal mode:
[DKNightVersionManager dawnComing];
It's pretty easy to swich theme between night and normal mode.
nightFalling
method will post DKNightVersionNightFallingNotification
when it is called. Similarly, dawnComing
will post DKNightVersionDawnComingNotification
. You can observe these notification in proper place, and make your own customize easily.
Feel free to open an issue or pull request, if you need help or there is a bug.
- Documentation
DKNightVersion is available under the MIT license. See the LICENSE file for more info.
The MIT License (MIT)
Copyright (c) 2015 Draveness
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.