6 Star 38 Fork 6

internetwei / llDark

Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
Clone or Download
Notice: Creating folder will generate an empty file .keep, because not support in Git


License MIT  Carthage  CocoaPods  Platform  Support

A dark theme framework for iOS, quickly and easily adapting to dark mode.
Mainland China users can accessThis link
github does not display picture solutions


  • The integration is very simple, only a few changes are required and the project structure will not be destroyed.
  • High performance, refresh the current page UI only when you need to refresh.
  • Powerful, covering all usage scenarios of UIColor, UIImage, CGColor.
  • Compatible with models below iOS13.
  • Support to obtain dark theme configuration from the Internet.
  • The automatic adaptation start-up picture is the current theme mode of the APP, and supports models below iOS13.
  • Support dynamic modification of any type of startup diagram.


Manual.gif System.gif Screen.gif LightVertical.gif



Configure dark resources: Create + (NSDictionary<id, id> *)llDarkTheme class method in any NSObject category of the project (it is recommended to create a separate category). The key of the dictionary represents the color/picture name/picture address under the light theme, and the dictionary’s Value represents the color/picture name/picture address under the dark theme. You can refer to the sample code:

+ (NSDictionary<id, id> *)llDarkTheme {
    return @{
             UIColor.whiteColor : kColorRGB(27, 27, 27),
             kColorRGB(240, 238, 245) : kColorRGB(39, 39, 39),
             [UIColor colorWithRed:14.0 / 255.0 green:255.0 / 255.0 blue:0.0 alpha:1.0] : [UIColor colorWithRed:0.0 green:14.0 / 255.0 blue:255.0 / 255.0 alpha:1.0],
             @"background_light" : @"background_dark",
             @"~/path/background_light.png" : @"~/path/background_dark.png",

Tips: 1.It is not necessary to fill in all colors/pictures in all cases. For dark colors that are occasionally or rarely used, you can refer to the advanced usage to adapt them separately. 2.if the picture path is filled in, the complete picture path (including the suffix) must be filled in.

Basic usage

UIColor and CGColor only need to append .themeColor(nil). UIImage only needs to replace imageNamed or imageWithContentsOfFile with themeImage.

// UIColor
UIColor.redColor; // Previous usage
UIColor.redColor.themeColor(nil); // Current usage

// CGColor
UIColor.redColor.CGColor; // Previous usage
UIColor.redColor.themeCGColor(nil); // Current usage

// UIImage
[UIImage imageNamed:@"lightImageName"]; // Previous usage
[UIImage themeImage:@"lightImageName"]; // Current usage

Tips: 1.themeImage is adapted to two methods, imageNamed and imageWithContentsOfFile, which can pass the image name or the image path. 2.Only the adapted Color and Image will be refreshed when the theme is switched.

Advanced usage

1. If the parameter in themeColor() is a specific Color object, the dark theme will refresh with the specified Color object.
If it is nil, it will return to the dark color refresh configured in llDarkTheme,
If llDarkTheme is not configured, it will return the color under the light theme.

2. The function of the themeCGColor() parameter is the same as the function of the themeColor() parameter.

3. themeImage() has 2 parameters, the parameter can be the image name or the image address,
The first parameter represents the picture used under the light theme (required),
The second parameter represents the picture used under the dark theme (can be empty),
If the second parameter is empty, the treatment is the same as if themeColor() is empty.

4. appearanceBindUpdaterAll objects inherited from UIView have this property,
It will be called when the object needs to be refreshed, and you can implement your own refresh logic here.
It is only called when a refresh is needed, and the theme change does not necessarily require refreshing the UI.

5. userInterfaceStyleSimilar to the overrideUserInterfaceStyle method of iOS13 system,
But the function is more powerful than overrideUserInterfaceStyle,
It supports all objects, such as CALayer.
It supports system usage below iOS13.

6. themeDidChangeAll objects have this property, which is the same as ThemeDidChangeNotification.
themeDidChange will be released when the object is released,
Can be used in multiple places, the callback order is not guaranteed,
Unlike appearanceBindUpdater, themeDidChange is called whenever the theme changes.

7. systemThemeDidChangeAll objects have this property, which is the same as SystemThemeDidChangeNotification.
The release timing is the same as themeDidChange,
Can be used in multiple places, the callback order is not guaranteed,
As long as the system theme changes, systemThemeDidChange will be called.

8. darkStyleAll UIImageView objects have this method to adapt to image objects without dark images, such as web images.
DarkStyle has 3 parameters. The first parameter determines how to adapt to the dark theme. There are currently two types: LLDarkStyleSaturation and LLDarkStyleMask.
LLDarkStyleMask uses mask adaptation, and LLDarkStyleSaturation adapts by reducing the saturation of the original image.
The second parameter determines the transparency/saturation value of the mask. For specific usage, please refer to the source code comments.
The third parameter can be nil. When using LLDarkStyleSaturation, you need to pass a unique string as an identifier, usually the url of the image.
Sample code:
UIImageView *imageView = [[UIImageView alloc] init];
NSString *url = @"Picture URL";
imageView.darkStyle(LLDarkStyleSaturation, 0.2, url);
// imageView.darkStyle(LLDarkStyleMask, 0.5, nil);

9. updateDarkTheme:If you need to modify the dark theme configuration information at runtime, or need to obtain dark theme configuration information from the Internet, you can use updateDarkTheme: to achieve the goal.
Please ensure that the dark theme information is configured before the first UI object is loaded, otherwise it will be invalid.
Sample code:
NSDictionary *darkTheme = @{
    UIColor.whiteColor : kColorRGB(27, 27, 27),
    kColorRGB(240, 238, 245) : kColorRGB(39, 39, 39),
    [UIColor colorWithRed:14.0 / 255.0 green:255.0 / 255.0 blue:0.0 alpha:1.0] : [UIColor colorWithRed:0.0 green:14.0 / 255.0 blue:255.0 /  255.0 alpha:1.0],
    @"background_light" : @"background_dark",
    @"~/path/background_light.png" : @"~/path/background_dark.png",
[LLDarkSource updateDarkTheme:darkTheme];

10. thirdControlClassNameIf you need to support the refresh method of the third-party control, you can implement the refresh logic separately in appearanceBindUpdater, or you can implement the refresh logic according to the following methods, and the following methods are more recommended.
First, you need to implement the thirdControlClassName class method and return an array containing the class name string of the third party control.
Then implement the refresh+class name string object method, and implement the refresh logic of the third-party control in the method. You can refer to the YYLabel refresh logic that has been implemented in the LLThird.m file.
For details, you can download the project and view the Demo to understand the specific implementation.

11. If you need to support the adaptation of the dark startup image in iOS13 or lower, please name the dark image according to the specified rules and place it in any directory of the project.
Naming rule: launchImage_<screen width>_<screen height>.
For example: launchImage_414_736, this dark launch image will appear after switching to dark mode on models with a screen width of 414×736 and systems below iOS13.
If you want to adapt the horizontal image, you only need to exchange the width and height positions, for example: launchImage_736_414.
The specific effect can be viewed by running Demo on the system below iOS13 and switching to dark mode.
For specific naming, please refer to the image naming method under the LaunchImage folder in the Demo project. It contains the dark launch image of all models below iOS 13 (including horizontal screen, excluding models before iPhone 6).

12. LLLaunchScreen provides some class methods, reasonable use of these class methods can perfectly replace any startup image of APP, including "dark vertical launch Image", "dark horizontal launch Image", "light vertical launch Image", "Light horizontal launch Image".
Please refer to the LLLaunchScreen.h file for specific methods.
For usage method, please refer to Demo.

The sample diagram of darkStyle method No. 8 in advanced usage (in order to highlight the effect, the saturation and transparency are adjusted very low): 5fc91820394ac523788c48f4

Quick adaptation

It only takes 3 steps to quickly and perfectly adapt to the dark theme mode. After testing, most of the projects can be adapted within 0.5 days.

  1. To configure dark theme resources, refer to Prerequisites, or refer to Advanced Method 9 to obtain resource adaptation from the network.
  2. Adapt Color and Image that need to be adapted to theme Color and theme Image. For the adaptation method, please refer to Basic Usage and Advanced Usage.
  3. Run the project and check for completeness.


  1. If you still need to adapt WKWebView, you can click the linkRefer to the article for adaptation.
  2. By default, iOS13 and above systems will automatically adapt Launch Image to follow the changes in APP theme mode, if you want to use the system below iOS13 This function is also supported, please refer to Advanced Usage 11 and Advanced Usage 12.



  1. Add pod 'LLDark' to your Podfile.
  2. Run pod install --repo-update.
  3. Import <LLDark/LLDark.h>.


  1. Add github "internetWei/LLDark" to your Cartfile.
  2. Run carthage update --platform ios and add the framework to your project.
  3. Import <LLDark/LLDark.h>.


  1. Download all the files in the LLdark subdirectory.
  2. Add (drag and drop) the LLDark folder to your project.
  3. Import LLDark.h.


The project supports iOS 9.0 and Xcode 10.0 at least. If you want to use it on lower systems, please contact the author.


  1. LLDark does not modify the style of the status bar, you need to monitor the theme mode to modify the style of the status bar.
  2. The image resources that need to be adapted to the dark theme are not recommended to be placed in Assets.xcassets. The test found that the images in NSAttributedString will not be refreshed when the theme is switched (loaded with imageNamed:). This is a system bug. The solution is to put the image under the project and load it with themeImage:.
  3. UIImage instance object has an imageWithRenderingMode: method。Calling this method will regenerate and return a UIImage instance object,This will cause the normal refresh。Please use renderingModeFrom method instead。

Known issues

  • Other theme modes are not supported for the time being, and a variety of themes will be supported freely in the future.


If you have better improvements, please pull reqeust me

If you have any better comments, please create oneIssue

The author can be contacted by this emailinternetwei@foxmail.com


LLDark is released under the MIT license. See LICENSE file for details.

Repository Comments ( 0 )

Sign in to post a comment


适用于iOS的强大深色主题框架,能帮您快速适配深色模式。 expand collapse
Objective-C and 2 more languages

Releases (4)






Load More
can not load any more