Giter Site home page Giter Site logo

lvthemekit's Introduction

LVThemeKit

说明

App 多区域皮肤 UIKit Category

LVThemeKit/ObjC 适用于 OC 项目

LVThemeKit/Swift 适用于 Swift 项目

功能

  • UIKit Category
    • UIView
    • UIImageView
    • UILabel
    • UIButton
    • UISlider
  • QuartzCore Category
    • CALayer
    • CAShapeLayer
  • Resource
    • LVThemeColor
    • LVThemeImage
    • LVThemeString
    • LVThemeAttributedString
  • 其他,可以很容易的扩展

用法

  • UIView
// OC
self.label.viewTK.theme.backgroundColor = [LVThemeColor background];
self.label.viewTK.other.backgroundColor = [LVThemeColor otherBackground];
// Swift
label.viewTK.theme.backgroundColor = LVThemeColor.background
label.viewTK.other.backgroundColor = LVThemeColor.otherBackground
  • UIButton
// OC
[self.button.buttonTK.theme setImage:[LVThemeImage image] forState:UIControlStateNormal];
// Swift
button.buttonTK.theme.setImage(LVThemeImage.image, for: .normal)
  • CALayer
// OC
self.layer.layerTK.theme.borderColor = [LVThemeColor background];
// Swift
layer.layerTK.theme.borderColor = LVthemeColor.background

配置

  • LVThemeKitConfig
    • generators: 监听主题变化的通知数组,根据配置的数量生成主题数量
    • applyProperty: 当配置多套主题时,自定义应用顺序,默认是数组顺序
// OC
LVThemeKitConfig *conf = [[LVThemeKitConfig  alloc] init];
config.generators = @[[DayNightObserver class]];
LVThemeKit.config = conf;
// Swift
let conf = LVThemeKitConfig()
conf.generators = [DayNightObserver.self]
LVThemeKitConfig.config = conf

扩展

  • 扩展类,参考UIView/CALayer
  • 扩展属性
    • 支持 KVC,参考UIView.backgroundColor
    • 不支持 KVC,参考UIButton.setTitle:forState:
  • 替换已有的类,比如UIView.viewTK,可以新加一个属性UIView.x_viewTK

例子

安装

Cocoapods

pod 'LVThemeKit/ObjC'

或者

pod 'LVThemeKit/Swift'

类图

lvthemekit's People

Contributors

lvpengwei avatar

Watchers

James Cloos 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.