All Projects → netyouli → WHC_Layout

netyouli / WHC_Layout

Licence: MIT license
Swift iOS and Mac OS X platforms currently in use the fastest the simplest development to build the UI layout automatically open source library, strong dynamic layout constraint handling capacity,iOS/Mac OS X平台上目前使用最简单开发构建UI速度最快的自动布局开源库,强悍的动态布局约束处理能力

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to WHC Layout

Snapkit
A Swift Autolayout DSL for iOS & OS X
Stars: ✭ 18,091 (+32205.36%)
Mutual labels:  snapkit, autolayout
Driftwood
Driftwood is a DSL to make Auto Layout easy on iOS, tvOS and macOS.
Stars: ✭ 14 (-75%)
Mutual labels:  autolayout
Tswechat
A WeChat alternative. Written in Swift 5.
Stars: ✭ 3,674 (+6460.71%)
Mutual labels:  snapkit
GoneVisible
GoneVisible is a UIView extension that uses AutoLayout to add "gone" state like Android.
Stars: ✭ 27 (-51.79%)
Mutual labels:  autolayout
SDCAutoLayout
A UIView category that simplifies dealing with Auto Layout
Stars: ✭ 23 (-58.93%)
Mutual labels:  autolayout
awesome-demo-app
100% programmatically written in Swift. Clearly demonstrating the RxSwift, RxCocoa, RxRealm & SnapKit.
Stars: ✭ 16 (-71.43%)
Mutual labels:  snapkit
Ragrid
Intrinsic first auto-layout flexbox grid
Stars: ✭ 249 (+344.64%)
Mutual labels:  autolayout
JXLayerAutoLayout
优雅的实现CALayer AutoLayout
Stars: ✭ 19 (-66.07%)
Mutual labels:  autolayout
VanillaConstraints
🍦 Simplified and chainable AutoLayout constraints for iOS.
Stars: ✭ 42 (-25%)
Mutual labels:  autolayout
SideMenuSwiftDemo
SideMenu in Swift with autolayout
Stars: ✭ 79 (+41.07%)
Mutual labels:  autolayout
iOSProjects
It's project that contains different applications developed with Swift 5.7 👨‍💻👩🏼‍💻🧑🏿‍💻
Stars: ✭ 122 (+117.86%)
Mutual labels:  autolayout
StoryboardConstraint
A simple way to use programmatically Autolayout Constraint created in Storyboard.
Stars: ✭ 25 (-55.36%)
Mutual labels:  autolayout
StackableTableView
A UITableView subclass that enables setting an array of views for both headers and footers utilizing UIStackView
Stars: ✭ 72 (+28.57%)
Mutual labels:  autolayout
react-native-whc-loading
A react native module to show loading ui, it works on iOS and Android.
Stars: ✭ 32 (-42.86%)
Mutual labels:  whc
UseAutoLayout
UseAutoLayout @propertyWrapper for Swift
Stars: ✭ 25 (-55.36%)
Mutual labels:  autolayout
StackViewLayout
StackViewLayout is a slide card view
Stars: ✭ 24 (-57.14%)
Mutual labels:  stackview
Sequents
A simple continuous animation library for iOS UI.
Stars: ✭ 31 (-44.64%)
Mutual labels:  stackview
react-native-whc-calendar
A react native module to show calendar, it works on iOS and Android. 跨平台日历组件支持iOS、Android
Stars: ✭ 28 (-50%)
Mutual labels:  whc
Cassowary
High performance swift implement of constraint solving algorithm cassowary
Stars: ✭ 45 (-19.64%)
Mutual labels:  autolayout
Constrainable
simple declarative autolayout µframework based on Swift 4 KeyPath
Stars: ✭ 26 (-53.57%)
Mutual labels:  autolayout

WHC_Layout (Swift)


Build Status Pod Version Platform Pod License

  • iOS and Mac OS X platforms currently in use the fastest the simplest development to build the UI layout automatically open source library, strong dynamic layout constraint handling capacity
  • Service to update constraints, convenient and quick dynamic UI layout.

Objective-c version 👉 WHC_AutoLayout

布局api内部自动支持兼容处理iphonex头部齐刘海和底部黑线

添加UILayoutGuide,safeAreaLayoutGuide约束支持

重构布局核心升级基于二叉树层遍历算法搜索约束主视图,对于自动处理跨视图层复杂约束关系更健壮从容

封装集成抗拉伸和抗压缩api支持链式调用

Introduce

  • Adopt chain layout Api calls convenient
  • Include one line of code to calculate UITableViewCell highly module
  • Contains WHC_StackView module (UIStackView purpose alternative system)
  • Automatic identification of the same type conflict and update the new constraints
  • Support change constraints priority
  • Support delete constraints
  • Support iOS and Mac OS X
  • Automatic covering and modify the conflict with type constraints

Require

  • iOS 8.0+ / Mac OS X 10.11+ / tvOS 9.0+
  • Xcode 8.0 or later
  • Swift 5.1
  • If you want to use swift3.2, please pod WHC_Layout '~> 1.0.9'

Note

  • When the view call removeFromSuperview() the view must call whc_ResetConstraints() to clear the cache constraint
  • Swift5 + has abandoned the initialize class method, and if you need to use the automatic computing UITableViewCell height, you can call UITableview.whc_initconfig () in the AppDelegate initialization method.

Install

  • CocoaPods: pod 'WHC_Layout'

Usage

UILayoutGuide,safeAreaLayoutGuide

let guide = UILayoutGuide()
let view = UIView()

guide.whc_Left(10)
.whc_Top(0, toView: self.view.safeAreaLayoutGuide)
.whc_Right(10)
.whc_Height(30)

view.whc_Left(10)
.whc_Right(10)
.whc_Top(0, toView: guide)
.whc_Height(50)

Automatic height view

view.whc_Left(10)
    .whc_Top(10)
    .whc_Right(10)
    .whc_HeightAuto()

Use lessEqual or greaterEqual (width <= 100 && width >= 20)

view.whc_Width(100).whc_LessOrEqual()
    .whc_Width(20).whc_GreaterOrEqual()

SnapKit/Masonry update the constraint way unfriendly

view.snp.updateConstraints {(make) -> Void in
    make.top.equalTo(superview.snp_top).with.offset(10) 
    make.left.equalTo(superview.snp_left).with.offset(20)
    make.bottom.equalTo(superview.snp_bottom).with.offset(-10)
    make.right.equalTo(superview.snp_right).with.offset(-10)
}

Update the view constraints

Modify the view to the left from 20 other views

view.whc_Left(20)
// or
view.whc_Left(20, toView: otherView)

Can be directly modified constraints on the Xib and Storyboard

If the view of xib leading now amended as left constraints

/// First remove the xib view of leading and then add new constraints
view.whc_RemoveAttrs(.leading)
    .whc_Left(10)

Remove the constraint

Remove all constraints associated with view left

view.whc_RemoveAttrs(.left)

To remove multiple constraints associated with view

view.whc_RemoveAttrs(.left, .leading, .top)
// or 
view.whc_RemoveTo(linkView, attrs: .left ...)

Modify the view constraint priority

Modify the view constraint for low priority right

view.whc_Right(10)
    .whc_PriorityLow()
// The higher the priority, the less likely to be stretched
// 设置抗拉伸优先级,优先级越高越不容易被拉伸
label.whc_ContentHuggingPriority(.defaultLow, for: .horizontal)

// 设置抗压缩优先级,优先级越高越不容易被压缩
// Compression priority, the higher the priority the less easy to be compressed
label.whc_ContentCompressionResistancePriority(.defaultLow, for: .horizontal)

One line of code calculation cell height

No reuse way calculated cell height

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
    return UITableViewCell.whc_CellHeightForIndexPath(indexPath, tableView: tableView)
}

Reuse way calculated cell height

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
    return UITableViewCell.whc_CellHeightForIndexPath(indexPath, 
                                    tableView: tableView, 
                                    identifier: "kFirendsCircleCellIdentifier",
                                    layoutBlock: { (cell) in
        /// use model layout cell
        cell.setFriendModel(model)
    })
}

Use WHC_StackView

Create WHC_StackView

let stackView = WHC_StackView()
self.view.addSubview(stackView)

Add constraint

stackView.whc_Left(10)
         .whc_Top(10)
         .whc_Right(10)
         .whc_HeightAuto()

Configuration stackView

1. Set the padding

stackView.whc_Edge = UIEdgeInsetsMake(10, 10, 10, 10) // 内边距

2. Set the layout direction

stackView.whc_Orientation = .Vertical                  // 自动垂直布局

3. Set the child views lateral clearance

stackView.whc_HSpace = 10                             // 子视图横向间隙

4. Set the child views vertical clearance

stackView.whc_VSpace = 10                             // 子视图垂直间隙

5. Add subview and start the layout

for _ in 0 ... 3 {
    let view = UIView()
    stackView.addSubview(view)        
}
stackView.whc_StartLayout()

Prompt

For more UI layout automatically, WHC_StackView components, one line of code to calculate the cell height module, please download this demo to check the specific usage

Licenses

All source code is licensed under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].