Git Product home page Git Product logo

ztchain's Introduction

ZTChain

ZTChain is a lightweight library designed to facilitate chaining syntax in Swift, making your code more readable and expressive.

Features

1. Chainable Syntax

  • Allows for concise and readable code by chaining multiple method calls.
  • Example: view.zt.backgroundColor(.red).cornerRadius(10).borderWidth(2)

2. Dynamic Member Lookup

  • Utilizes Swift’s @dynamicMemberLookup to provide a flexible and clean API.
  • Example: view.zt.title("Welcome").subtitle("Hello World!")

3. Type-Safe Key Paths

  • Uses Swift’s key paths to ensure type safety when accessing properties.

4. Compatibility with UIKit

  • Extends commonly used UIKit components like UIView, UILabel, UIButton, etc.
  • Example: button.zt.title("Click Me").backgroundColor(.blue)

5. Custom Wrappers

  • Allows for easy creation of custom wrappers for any class or struct.
  • Example: MyCustomView().zt.customStyle

6. Fluent Interface Design

  • Provides a fluent interface design pattern for improved code readability and maintainability.
  • Example: textField.zt.placeholder("Enter name").textColor(.gray)

7. Extendable

  • Easily extendable to support additional custom styles and properties.
  • Example: extension ZTWrapper where Subject: UIButton { ... }

8. Supports iOS 11

  • Compatible with iOS 11 and later versions.

9. Supports Xcode Build Checks

  • Integrates seamlessly with Xcode, ensuring build checks and validation.

10. Supports Xcode Editor Code Suggestions and Autocompletion

  • Provides full support for code suggestions and autocompletion in Xcode editor.

11. Lightweight and Compact

  • The entire library is contained within a single file, making it easy to integrate and manage.

12. Seamless Integration with Third-Party Libraries

  • Easily integrates with third-party libraries for extending UIKit properties.

Installation

Swift Package Manager

To integrate using Apple's Swift Package Manager, add the following as a dependency to your Package.swift:

dependencies: [
    .package(url: "https://github.com/willonboy/ZTChain.git", .upToNextMajor(from: "1.0.0"))
]

CocoaPods

To integrate using CocoaPods, add the following to your Podfile:

pod 'ZTChain', '~> 1.0.0'

Usage

Basic Example

import UIKit
import ZTChain


let tipsLbl = UILabel().zt
    .frame(CGRect(x: 20, y: 200, width: 350, height: 100))
    .textAlignment(.center)
    .font(.boldSystemFont(ofSize: 18))
    .textColor(.systemPink)
    .numberOfLines(10)
    .lineBreakMode(.byWordWrapping)
    .backgroundColor(.systemGray)
    .text("ZTChain is a lightweight library designed to facilitate chaining syntax in Swift, making your code more readable and expressive.")
    .subject

License

This project is licensed under the MPL-2.0.

ztchain's People

Contributors

willonboy avatar

Stargazers

 avatar majun avatar Yonghyun avatar houseme avatar  avatar Shaw Yan avatar Ahn Jung Min avatar SunJunXiang avatar James Y avatar Vince Liu avatar  avatar Colin avatar Benjamin avatar DG avatar

Watchers

 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.