Giter Site home page Giter Site logo

dknightversion's Introduction

  • UIColor support
  • UIImage and UIImageView 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

Demo

Installation with CocoaPods

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.

New Realease 1.4

  • Version 1.4 has some incampatiable changing, this version will change picker's setter method to dk_setBackgroundColorPicker instead of setDk_BackgroundColorPicker which is not elegant.

Podfile

Run following script in termianl

$ pod update

Add this line to your podfile

pod "DKNightVersion", "~> 1.4"

Usage

Just add one line of code in your precompiled header, or import it where you need.

#import "DKNightVersion.h"

How to use

Night color

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]);

Night Image

DKNightVersion providing new API to support image switching.

imageView.dk_imagePicker = DKImageWithNames(@"normal1", @"night1");

DKColor

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;

DKColorTable

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

DKImage is similar with DKColor which contains methods to generate DKImagePicker

DKImagePicker DKImageWithNames(NSString *normal, NSString *night);
DKImagePicker DKImageWithImages(UIImage *normal, UIImage *night);

Using DKNightVersionManager change theme

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.

Make your own customize

Notification

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.

Contribute

Feel free to open an issue or pull request, if you need help or there is a bug.

Contact

Todo

  • Documentation

License

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.

dknightversion's People

Contributors

bromine0x23 avatar chrisballinger avatar draveness avatar kiliankoe avatar nathanwhy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.