Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
This repository was archived by the owner on Jan 5, 2020. It is now read-only.
/NightNightPublic archive

Elegant way to integrate night mode to swift projects

License

NotificationsYou must be signed in to change notification settings

draveness/NightNight

Repository files navigation

Travis StatusCocoaPods compatibleCarthage compatiblePlatform

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

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

letview=UIView()view.mixedBackgroundColor=MixedColor(normal:0xffffff, night:0x000000)letimageView=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

  • UseMixedColor instead ofUIColor

    letview=UIView()view.mixedBackgroundColor=MixedColor(normal:0xffffff, night:0x000000)
  • UseMixedImage instead ofUIImage

    letimageView=UIImageView()imageView.mixedImage=MixedImage(normal: normal, night: night)
  • SupportNSAttributedString

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

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

    NightNight.theme=.NORMALNightNight.theme=.NIGHT

Customize

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

publicletNightNightThemeChangeNotification

Demo

Installation

Carthage

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

You can install Carthage withHomebrew using the following command:

$ brew update$ brew install carthage

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

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 yourPodfile:

use_frameworks!pod'NightNight'

Manually

  1. Download and dropNightNight/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 copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, 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 THESOFTWARE.


[8]ページ先頭

©2009-2025 Movatter.jp