GithubHelp home page GithubHelp logo

hzrzcw / autoinch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lixiang1994/autoinch

0.0 1.0 0.0 1.07 MB

优雅的iPhone全尺寸/等比例精准适配工具

License: MIT License

Swift 94.72% Ruby 2.94% Objective-C 2.34%

autoinch's Introduction

AutoInch - 优雅的iPhone等比例/全尺寸精准适配工具

  Swift

Features

  • Numerical type fast conversion
  • Storyboard equal scale adaptation
  • Xib equal scale adaptation
  • Custom calculation processing
  • Quick match for each screen size type

Installation

CocoaPods - Podfile

pod 'AutoInch'

Carthage - Cartfile

github "lixiang1994/AutoInch"

Usage

First make sure to import the framework:

import AutoInch

Here are some usage examples. All devices are also available as simulators:

Auto

AutoLayout (SnapKit):

private func setupLayout() {
    cardView.snp.makeConstraints { (make) in
	make.top.equalTo(16.auto())
	make.left.right.equalToSuperview().inset(15.auto())
	make.bottom.equalTo(-26.auto())
    }
	
    lineView.snp.makeConstraints { (make) in
	make.left.right.equalToSuperview().inset(15.auto())
	make.top.equalTo(titleLabel.snp.bottom)
	make.height.equalTo(1)
    }
        
    titleLabel.snp.makeConstraints { (make) in
        make.top.equalToSuperview()
        make.left.equalTo(15.auto())
        make.height.equalTo(48.auto())
    }
        
    stateLabel.snp.makeConstraints { (make) in
        make.top.equalTo(lineView).offset(10.auto())
        make.left.equalTo(15.auto())
        make.height.equalTo(15.auto())
    }
}

Property (Then):

private lazy var cardView = UIView().then {
    $0.cornerRadius = 6.auto()
    $0.backgroundColor = .white
}

private lazy var lineView = UIView().then {
    $0.backgroundColor = .hex("000000", alpha: 0.05)
}

private lazy var titleLabel = UILabel().then {
    $0.textColor = .black
    $0.font = .systemFont(ofSize: 20.auto(), weight: .medium)
}

private lazy var stateLabel = UILabel().then {
    $0.textColor = .gray
    $0.font = .systemFont(ofSize: 12.auto(), weight: .medium)
}

Storyboard / Xib:

Constraint UILabel Font

Inch

e.g.

// default other screen numberOfLines = 0
// 3.5 inches screen numberOfLines = 1
// 4.0 inches screen numberOfLines = 2
label.numberOfLines = 0.i35(1).i40(2)

all

print("this is " +
    "default"
    .i35("3.5 inches (iPhone 4, 4s)")
    .i40("3.5 inches (iPhone 5, 5s, SE)")
    .i47("3.5 inches (iPhone 6, 7, 8)")
    .i55("3.5 inches (iPhone 6, 7, 8 Plus)")
    .ifull("full screen (iPhone X, Xs, XsMax)")
    .i58full("5.8 inches (iPhone X, Xs)")
    .i61full("6.1 inches (iPhone XR)")
    .i65full("6.5 inches (iPhone XsMax)")
)

Screenshot

TikTok 1

TikTok 2

Contributing

If you have the need for a specific feature that you want implemented or if you experienced a bug, please open an issue. If you extended the functionality of AutoInch yourself and want others to use it too, please submit a pull request.

License

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

autoinch's People

Contributors

lixiang1994 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.