• This repository has been archived on 05/Jan/2020
  • Stars
    star
    776
  • Rank 58,561 (Top 2 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 8 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Elegant way to integrate night mode to swift projects

Travis Status CocoaPods compatible Carthage compatible Platform

NightNight makes it easy to integrate night mode. It provides multiple APIs which all contain keyword mixed.

If you want to implement night mode in Objective-C project without import swift code. This is the Objective-C version DKNightVersion

let view = UIView()
view.mixedBackgroundColor = MixedColor(normal: 0xffffff, night: 0x000000)

let imageView = UIImageView()
imageView.mixedImage = MixedImage(normal: UIImage(named: "normal"), night: UIImage(named: "night")) 

FeaturesUsageCustomizeDemoInstallationLicense

Features

  • Integrate night mode easily
  • UIColor and UIImage support
  • Support NSAttributedString
  • Better autocompletion
  • Customize with notification

Usage

  • Use MixedColor instead of UIColor

    let view = UIView()
    
    view.mixedBackgroundColor = MixedColor(normal: 0xffffff, night: 0x000000)
  • Use MixedImage instead of UIImage

    let imageView = UIImageView()
    
    imageView.mixedImage = MixedImage(normal: normal, night: night)
  • Support NSAttributedString

    let attributedString = NSMutableAttributedString(string: "NightNight")
    attributedString.setMixedAttributes(
        [NNForegroundColorAttributeName: MixedColor(normal: 0x000000, night: 0xfafafa)],
        range: NSRange(location: 0, length: 9)
    )
    
    public let NNForegroundColorAttributeName
    public let NNBackgroundColorAttributeName
    public let NNUnderlineColorAttributeName
  • NavigationBar barStyle

    let navigationBar = navigationController?.navigationBar
    
    navigationBar.mixedBarStyle = MixedBarStyle(normal: .Default, night: .Black)
  • Change current theme to .NORMAL or .NIGHT

    NightNight.theme = .NORMAL
    NightNight.theme = .NIGHT

Customize

NightNight will send NightNightThemeChangeNotification. if you wanna some customize features, you can observe it and change what you want in corresponding selector.

public let NightNightThemeChangeNotification

Demo

Installation

Carthage

Carthage is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate NightNight into your Xcode project using Carthage, specify it in your Cartfile:

github "draveness/NightNight"

Cocoapods

CocoaPods is a dependency manager for Cocoa projects.

You can install it with the following command:

$ gem install cocoapods

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

use_frameworks!

pod 'NightNight'

Manually

  1. Download and drop NightNight/Classesfolder in your project.
  2. Congratulations!

License

Copyright (c) 2016 Draveness (http://github.com/draveness)

NightNight is available under the MIT license. See the LICENSE file for more info.

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.

More Repositories

1

analyze

Draven's Blog
Objective-C
8,101
star
2

DKNightVersion

Manage Colors, Integrate Night/Multiple Themes. (Unmaintained)
Objective-C
3,556
star
3

DKChainableAnimationKit

A DSL to make animation easy on iOS with Swift.
Swift
1,894
star
4

Typeset

Deal with AttributedString efficiently
Objective-C
450
star
5

RbSwift

Extensions for Swift with hundreds of handy methods.
Swift
320
star
6

go-internal

《Go 语言设计与实现》示例代码
Go
268
star
7

Ouroboros

🐍 ObjectiveC library for magical scroll interactions.
Objective-C
149
star
8

blog-comments

面向信仰编程
140
star
9

ATProperty

☀️ Create @property with shortcut
Objective-C
135
star
10

proxier

A better approach to expose application in Kubernetes.
Go
109
star
11

linux-archive

Linux archive for studying the process scheduler. 调度系统设计精要 http://draveness.me/system-design-scheduler
C
88
star
12

JSONCop

A better way to deal with JSON parsing in Swift.
Ruby
30
star
13

Mineral

A library used to separate concerns from the original UIKit framework.
Swift
29
star
14

ChainableKit

Chainable UIKit in Objective-C
Objective-C
27
star
15

oceanbook

A Modern Matching Engine without documentation YET [alpha]
Go
25
star
16

Crotalus

Elegant approach to create AttributedString in swift
Swift
19
star
17

SpaceShuttle

🚀 A library manages Inter-View value passing
Objective-C
13
star
18

go-utils

Go
11
star
19

OKObserver

A lightweight wrapper for KVO, bind view and model easily
Objective-C
11
star
20

draveness

10
star
21

git-ignore

Rust
3
star
22

tmpwatch-controller

Dockerfile
2
star
23

gitbook-plugin-gitalk

JavaScript
2
star
24

Daytabase

An key/value store database built atop sqlite
Swift
1
star