Giter Site home page Giter Site logo

draveness / dknightversion Goto Github PK

View Code? Open in Web Editor NEW
3.6K 91.0 517.0 9.97 MB

Manage Colors, Integrate Night/Multiple Themes. (Unmaintained)

License: MIT License

Objective-C 69.20% Ruby 10.04% HTML 1.08% C 19.68%
theme objective-c night-mode dknightversion cocoapods mode colors

dknightversion's Introduction

  • Easily integrate and high performance
  • Providing UIKit and CoreAnimation category
  • Read colour customisation from file
  • Support different themes
  • Generate picker for other libs with one line macro

Demo


If you want to implement night mode in Swift project without import Objective-C code. NightNight is the Swift version which does the same work.

How To Get Started

DKNightVersion supports multiple methods for installing the library in a project.

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.

Podfile

To integrate DKNightVersion into your Xcode project using CocoaPods, specify it in your Podfile:

pod "DKNightVersion"

Then, run the following command:

$ pod install

Import

Import DKNightVersion header file

#import <DKNightVersion/DKNightVersion.h>

Usage

Checkout DKColorTable.txt file in your project, which locates in Pods/DKNightVersion/Resources/DKNightVersion.txt.

NORMAL   NIGHT
#ffffff  #343434 BG
#aaaaaa  #313131 SEP

You can also create another colour table file, and specify it with DKColorTable.

A, set color picker like this with DKColorPickerWithKey, which generates a DKColorPicker block

self.view.dk_backgroundColorPicker = DKColorPickerWithKey(BG);

After the current theme version change to DKThemeVersionNight, the view background colour would switch to #343434.

[DKNightVersionManager nightFalling];

Alternatively, you could change the theme version by manager's property themeVersion which is a string

DKNightVersionManager *manager = [DKNightVersionManager sharedInstance];
manager.themeVersion = DKThemeVersionNormal;

Advanced Usage

There are two approaches you can use to integrate night mode to your iOS App.

DKNightVersionManager

The latest version for DKNightVersion add a readonly dk_manager property for NSObject returns the DKNightVersionManager singleton.

Change Theme

You can call nightFalling or dawnComing to switch the current theme version to DKThemeVersionNight or DKThemeVersionNormal.

[self.dk_manager dawnComing];
[self.dk_manager nightFalling];

Modify themeVersion property to switch the theme version directly.

self.dk_manager.themeVersion = DKThemeVersionNormal;
self.dk_manager.themeVersion = DKThemeVersionNight;
// if there is a RED column in DKColorTable.txt (default) or in 
// other `file` if you customize `file` property for `DKColorTable`
self.dk_manager.themeVersion = @"RED"; 

Post Notification

Every time the current theme version changes, DKNightVersionManager would post a DKNightVersionThemeChangingNotification. If you want to do some customisation, you can observe this notification and react with proper actions.

DKColorPicker

DKColorPicker is the core of DKNightVersion. And this lib adds dk_colorPicker to every UIKit and Core Animation components. Ex:

@property (nonatomic, copy, setter = dk_setBackgroundColorPicker:) DKColorPicker dk_backgroundColorPicker;
@property (nonatomic, copy, setter = dk_setTintColorPicker:) DKColorPicker dk_tintColorPicker;

DKColorPicker is defined in DKColor.h file receives a DKThemeVersion as the parameter and returns a UIColor.

typedef UIColor *(^DKColorPicker)(DKThemeVersion *themeVersion);
  • Use DKColorPickerWithKey(key) to obtain DKColorPicker from DKColorTable

    view.dk_backgroundColorPicker = DKColorPickerWithKey(BG);
  • Use DKColorPickerWithRGB to generate a DKColorPicker

    view.dk_backgroundColorPicker =  DKColorPickerWithRGB(0xffffff, 0x343434);

DKColorTable

DKColorTable is a new feature in DKNightVersion which providing us with an elegant way to manage colour setting in a project. Use as follows:

There is a file called DKColorTable.txt

NORMAL   NIGHT
#ffffff  #343434 BG
#aaaaaa  #313131 SEP

The first line of this file indicated different themes. NORMAL is required column, and others are optional. So if you don't need to integrate different themes in your app, leave the first column in this file, like this:

NORMAL
#ffffff BG
#aaaaaa SEP

NORMAL and NIGHT are two different themes, NORMAL is the default and for normal mode. NIGHT is optional and for night mode.

You can add multiple columns in this DKColorTable.txt file as many as you want.

NORMAL   NIGHT    RED
#ffffff  #343434  #ff0000 BG
#aaaaaa  #313131  #ff0000 SEP

The last column is the key for a colour entry, DKNightVersion uses the current themeVersion (ex: NORMAL NIGHT and RED) and key (ex: BG, SEP) to find the corresponding colour in DKColorTable.

DKColorTable has a property file, it will loads the color setting in this file when + [DKColorTable sharedColorTable is called. Default value of file is DKColorTable.txt.

@property (nonatomic, strong) NSString *file;

You can also add another file into your project and fill your colour setting in that file.

// color.txt
NORMAL   NIGHT
#ffffff  #343434 BG

Also, do not forget to change the file property of the colour table.

[DKColorTable sharedColorTable].file = @"color.txt"

The code above would reload colour setting from color.txt file.

Create temporary DKColorPicker

If you'd want to create some temporary DKColorPicker, you can use these methods.

view.dk_backgroundColorPicker =  DKColorPickerWithRGB(0xffffff, 0x343434);

DKColorPickerWithRGB will return a DKColorPicker which set background color to #ffffff when current theme version is DKThemeVersionNormal and #343434 when it is DKThemeVersionNight.

There are also some similar functions like DKColorPickerWithColors

DKColorPicker DKColorPickerWithRGB(NSUInteger normal, ...);
DKColorPicker DKColorPickerWithColors(UIColor *normalColor, ...);

DKColor also provides a cluster of convenient API which returns DKColorPicker block, these blocks return the same colour in different themes.

+ (DKColorPicker)colorPickerWithUIColor:(UIColor *)color;

+ (DKColorPicker)colorPickerWithWhite:(CGFloat)white alpha:(CGFloat)alpha;
+ (DKColorPicker)colorPickerWithHue:(CGFloat)hue saturation:(CGFloat)saturation brightness:(CGFloat)brightness alpha:(CGFloat)alpha;
+ (DKColorPicker)colorPickerWithRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha;
+ (DKColorPicker)colorPickerWithCGColor:(CGColorRef)cgColor;
+ (DKColorPicker)colorPickerWithPatternImage:(UIImage *)image;
#if __has_include(<CoreImage/CoreImage.h>)
+ (DKColorPicker)colorPickerWithCIColor:(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;

pickerify

DKNightVersion provides a powerful feature which can generate dk_xxxColorPicker with a macro called pickerify.

@pickerify(TableViewCell, cellTintColor)

It automatically generates dk_cellTintColorPicker for you.

DKImagePicker

Use DKImagePicker to change images when manager.themeVersion changes.

imageView.dk_imagePicker = DKImagePickerWithNames(@"normal", @"night");

The first argument passed into the function is used for NORMAL theme, and the second is used for NIGHT theme, the themes order is determined by the configuration in DKColorTable.txt file which is NORMAL and NIGHT.

If your file like this:

NORMAL   NIGHT    RED
#ffffff  #343434  #fafafa BG
#aaaaaa  #313131  #aaaaaa SEP
#0000ff  #ffffff  #fa0000 TINT
#000000  #ffffff  #000000 TEXT
#ffffff  #444444  #ffffff BAR

Set your image picker in this order:

imageView.dk_imagePicker = DKImagePickerWithNames(@"normal", @"night", @"red");

The order of images or names is the same in DKColorTable.txt file.

DKImagePicker DKImagePickerWithImages(UIImage *normalImage, ...);
DKImagePicker DKImagePickerWithNames(NSString *normalName, ...);

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 fabiosoft avatar handya avatar kelvinqq avatar kiliankoe avatar nathanwhy avatar thomasguenzel avatar yichizhang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dknightversion's Issues

Increase Theme Dynamically

Hi, @draveness , as title said, it's a bit difficult to increase theme dynamically in one file (ColorTable.txt), so I think it's better to refactor and abstract picker getter layer and storage layer.

Limit:

  • all themes in one files.
  • picker getter layer strongly couple with storage layer.

Enhancement:

  • abstract picker getter layer and storage layer.

As A Result:

After refactor and abstract, we can save themes into respective file. and have custom picker getter from storage layer, which has been abstracted. if user can download theme, they only have to download one theme file, into sandbox, the directory structure maybe:

Documents
└── Themes
    ├── Night.theme
    ├── Normal.theme
    └── Summer.theme

if you think it right, and no time to refactor, I'm glad to send PR :) .

Crash on iOS8

Hi,Draveness
Your work great, like the sunshine. hah

At iPhone 6Plus, click cell and go into the detail view, then come back and change the neight mode, it will crash.

Wating for your message.

git clone 你的工程,然后运行demo就报这个错误

2015-07-29 23:39:27.586 DKNightVersion[5017:1450908] -[UIImageView setNormalImage:]: unrecognized selector sent to instance 0x15de163c0
2015-07-29 23:39:27.588 DKNightVersion[5017:1450908] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImageView setNormalImage:]: unrecognized selector sent to instance 0x15de163c0'
*** First throw call stack:
(0x1824842d8 0x1941500e4 0x18248b3a4 0x182488154 0x18238accc 0x1000b18cc 0x186f09f64 0x186ef363c 0x186ef34fc 0x186f565f8 0x186f561d8 0x186ef27b4 0x186ef25e8 0x186ef23f4 0x186ef2238 0x186f89338 0x186f0ab00 0x186f8726c 0x186f6c77c 0x186f6b5d0 0x186f69f00 0x187188fe4 0x18718770c 0x18acb93c8 0x18243c27c 0x18243b384 0x1824399a8 0x1823652d4 0x186f683d0 0x186f62f40 0x1000b1b44 0x1947faa08)
libc++abi.dylib: terminating with uncaught exception of type NSException

Can't Access DK- Properties in Swift

After installing the pod and importing '#import <DKNightVersion/DKNightVersion.h>' in my bridging header, I am able to view the .dk_textColorPicker attributes on UIKit elements, but XCode won't recognize DKColorWithColors, DKNightVersionManager, or anything similar...ideas?

怎么设置webView的夜间模式

在使用webView的时候如果使用普通的设置方式self.webView.dk_backgroundColorPicker = DKColorPickerWithKey(BAR);没有效果,应该如何设置呢?也就是说如何设置webView的背景颜色。

NoMethodError when executing rake command

I want to customize my own theme for night mode. However, when I finish editing the property.json and run rake, it raise an error.

The error log goes like this:

......
[Generate] Generating Classes/UIKit/UITableViewCell/UITableViewCell+BackgroundColor.m
[Link] Find pbxproj file path
[Link] pbxproj is at '.././Pods.xcodeproj'
[Link] Linking to xcodeproj
rake aborted!
NoMethodError: undefined method `source_build_phase' for nil:NilClass
/path/to/Pods/DKNightVersion/generator/lib/generator/project.rb:59:in `clear_target'
/path/to/Pods/DKNightVersion/generator/lib/generator/project.rb:14:in `add_files_to_project'
/path/to/Pods/DKNightVersion/Rakefile:25:in `block in <top (required)>'
~/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `eval'
~/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => default
(See full trace by running task with --trace)

I'm not in good command of ruby, sorry.

引入文件后,全局设置UINavgation样式不生效

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.

    ViewController *view = [[ViewController alloc] init];
    UINavigationController *mainNav = [[UINavigationController alloc] initWithRootViewController:view];
    self.window.rootViewController = mainNav;

//这两个设置不生效,请问下是怎么回事。。。。
[[UINavigationBar appearance] setBarTintColor:[UIColor redColor]];

[[UINavigationBar appearance] setTintColor:[UIColor yellowColor]];



return YES;

}

改变不同日间和夜间模式的文字

在可以修改日间和夜间模式的图片,如何动态修改日间和夜间模式下按钮显示不同文字呢?好像通知可以实现,但是控件需要改成成员变量,不同通知有没有和imageView一样可以设置两种状态下的显示文字呢?

很诡异的BUG,看不出来

只能给你LOG日志。我有空我再瞅瞅。

0   CoreFoundation                  0x18530cf48 __exceptionPreprocess + 124
1   libobjc.A.dylib                 0x199ebff80 objc_exception_throw + 56
2   CoreFoundation                  0x18530ce90 +[NSException raise:format:] + 120
3   APP                             0x100cb34d0 UmengSignalHandler + 128
4   libsystem_platform.dylib        0x19a8ed93c _sigtramp + 52
5   APP                             0x1000a9494 __36-[UIButton(Night) night_updateColor]_block_invoke (UIButton+Night.m:76)
6   CoreFoundation                  0x1851f8cf8 __65-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 120
7   CoreFoundation                  0x1851f8bd0 -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 180
8   APP                             0x1000a9324 -[UIButton(Night) night_updateColor] (UIButton+Night.m:54)
9   CoreFoundation                  0x1852b260c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
10  CoreFoundation                  0x1852b1e2c _CFXRegistrationPost + 396
11  CoreFoundation                  0x1852b1bac ___CFXNotificationPost_block_invoke + 60
12  CoreFoundation                  0x185317424 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1532
13  CoreFoundation                  0x1851f2714 _CFXNotificationPost + 368
14  Foundation                      0x186162dcc -[NSNotificationCenter postNotificationName:object:userInfo:] + 68
15  APP                             0x1001669a4 -[DKNightVersionManager setThemeVersion:] (DKNightVersionManager.m:62)

显示的时这个函数的

- (void)night_updateColor {
    [self.pickers enumerateKeysAndObjectsUsingBlock:^(NSString * _Nonnull key, id  _Nonnull obj, BOOL * _Nonnull stop) {
        if ([obj isKindOfClass:[NSDictionary class]]) {
            NSDictionary<NSString *, DKColorPicker> *dictionary = (NSDictionary *)obj;
            [dictionary enumerateKeysAndObjectsUsingBlock:^(NSString * _Nonnull selector, DKColorPicker  _Nonnull picker, BOOL * _Nonnull stop) {
                UIControlState state = [key integerValue];
                [UIView animateWithDuration:DKNightVersionAnimationDuration
                                 animations:^{
                                     if ([selector isEqualToString:NSStringFromSelector(@selector(setTitleColor:forState:))]) {
                                         UIColor *resultColor = picker(self.dk_manager.themeVersion);
                                         [self setTitleColor:resultColor forState:state];
                                     } else if ([selector isEqualToString:NSStringFromSelector(@selector(setBackgroundImage:forState:))]) {
                                         UIImage *resultImage = ((DKImagePicker)picker)(self.dk_manager.themeVersion);
                                         [self setBackgroundImage:resultImage forState:state];
                                     } else if ([selector isEqualToString:NSStringFromSelector(@selector(setImage:forState:))]) {
                                         UIImage *resultImage = ((DKImagePicker)picker)(self.dk_manager.themeVersion);
                                         [self setImage:resultImage forState:state];
                                     }
                                 }];
            }];
        } else {
            SEL sel = NSSelectorFromString(key);
            DKColorPicker picker = (DKColorPicker)obj;
            UIColor *resultColor = picker(self.dk_manager.themeVersion);
            [UIView animateWithDuration:DKNightVersionAnimationDuration
                             animations:^{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
                                 [self performSelector:sel withObject:resultColor];
#pragma clang diagnostic pop
                             }];

        }
    }];
}

这一行

UIColor *resultColor = picker(self.dk_manager.themeVersion);

最关键的不是必现的。很难重现。

有些需要完善的地方,

在tableViewCell点击的时候设置了,[self.tableView deselectRowAtIndexPath:indexPath animated:YES]; // 取消选中状态,在日间模式下选中到取消选中过度很流畅,但是夜间模式会有跳跃,在突然冲选中到取消;对于键盘的夜间模式:发现在夜间模式下也对textFile做了处理,感觉很不错,但是textView和searchBar没有做出相应的处理希望能够完善。还有在已经完成的项目中添加这个库,我使用的办法是在每一个控件都添加一句代码实现夜间模式,你有什么好的建议来更好的使用这个库吗?

请教

看了下源代码,思路清晰,功能强大👍。有两个疑问:
1.代码收敛方面,现在还是需要在原来代码基础上添加setDk_backgroundColorPicker等方法,如果项目需要替换为另一个夜间模式库,那样的话重构成本会很大。有没有考虑在不破坏原有项目代码基础上实现,比如夜间模式配置文件?
2.有没有办法添加通用的夜间颜色属性,比如所有的UITableView的backgroundColor都共用一个颜色

Cocoa Pods重新pod install 后报错?

之前可以正常编译运行,重新pod install后报错。
是版本更新的问题吗?按照readme的文档改了之后还是报错。

_backView.dk_backgroundColorPicker = DKColorWithColors(KCOLOR_YELLOW_FDF5D8, [UIColor colorWithRGBHex:0x343434]);

Implicit declaration of function 'DKColorWithColors' is invalid in C99

Implicit conversion of 'int' to 'DKColorPicker' (aka 'UIColor *(^)(DKThemeVersion *__strong)') is disallowed with ARC

Invalid block pointer conversion assigning to 'DKColorPicker' (aka 'UIColor *(^)(DKThemeVersion *__strong)') from 'int'

[__NSMallocBlock__ set]: unrecognized selector sent to instance

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSMallocBlock set]: unrecognized selector sent to instance 0x14eaa5ba0

你好,在运行的时候回出现这个错误,不是必现的,偶尔会出现这个崩溃。

Can't not support XIB

In Demo

  1. create TestTableViewCell class, also create xib.
  2. dray label and button, layout like TableViewCell, set the text color (Red or else) using xib
  3. don't set textColor for TestTableViewCell, only set nightTextColor, like this
- (void)awakeFromNib {
    [DKNightVersionManager addClassToSet:self.class];

    self.label.numberOfLines = 0;
    self.label.text = @"DKNightVersion is a light wei-ght framework adding night   version to your iOS app.";
//    self.label.textColor = [UIColor darkGrayColor];
    self.label.lineBreakMode = NSLineBreakByCharWrapping;
    self.nightBackgroundColor = UIColorFromRGB(0x343434);
}
  1. register this nib, and use it replace TableViewCell
  2. run
  3. switch night and day theme, then you will see label color can't change back to Red color.

I think this code cause the problem:

- (void)hook_setTextColor:(UIColor*)textColor {
    if ([DKNightVersionManager currentThemeVersion] == DKThemeVersionNormal) [self setNormalTextColor:textColor];
    [self hook_setTextColor:textColor];
}

May be UILabel don't call setTextColor: method, instead directyly using _textColor = [UIColor xxxColor]

按钮根据不同状态设置颜色有问题

您好,引入夜间模式以后,根据不同的状态设置按钮文字颜色出现问题,按钮文字的颜色总是以最后一次设置的为准,代码如下:
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.frame = self.view.bounds;
[btn setTitle:@"hh" forState:UIControlStateNormal];
[btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[btn setTitle:@"ss" forState:UIControlStateSelected];
[btn setTitleColor:[UIColor orangeColor] forState:UIControlStateSelected];
[btn addTarget:self action:@selector(btnaction:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];

btn 的 titleColor 默认为 [UIColor orangeColor];
如果这样写的话
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.frame = self.view.bounds;
[btn setTitle:@"hh" forState:UIControlStateNormal];
[btn setTitle:@"ss" forState:UIControlStateSelected];
[btn setTitleColor:[UIColor orangeColor] forState:UIControlStateSelected];
[btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[btn addTarget:self action:@selector(btnaction:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];

btn的titleColor为 [UIColor whiteColor]

即引入夜间模式后,根据不同状态设置按钮titleColor失效,希望您能给我看下,谢谢。

Test testManagerUseDefaultThemeVersion is broken

/DKNightVersion/DKNightVersionTests/DKNightVersionManagerTest.m:33:36: Use of undeclared identifier 'DKNightVersion'

/DKNightVersion/DKNightVersionTests/DKNightVersionManagerTest.m:35:28: No known class method for selector 'setUseDefaultNightColor:'

/DKNightVersion/DKNightVersionTests/DKNightVersionManagerTest.m:36:53: No known class method for selector 'useDefaultNightColor'

xcode 6.3, iOS 8.3

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.