Swiftpack.co - kennic/FrameLayoutKit as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
kennic/FrameLayoutKit
FrameLayoutKit is a super fast and easy to use autolayout kit
.package(url: "https://github.com/kennic/FrameLayoutKit.git", from: "6.4.0")

FrameLayoutKit

Platform Language Version SwiftPM Compatible License

image

FrameLayout is a super fast and easy to use layout library for iOS and tvOS.

For Objective-C version: NKFrameLayoutKit (Deprecated, not recommended)

Why?

Say NO to autolayout constraint nightmare:

NO YES

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

FrameLayoutKit is available through Swift Package Manager (Recommended) and CocoaPods:

pod "FrameLayoutKit"

Example

This is how FrameLayoutKit layout the card view below:

let frameLayout = HStackLayout {
  $0.add(VStackLayout {
    $0.add(earthImageView).alignment = (.top, .center)
    $0.addSpace().flexible()
    $0.add(rocketImageView).alignment = (.center, .center)
  })
		
  $0.add(VStackLayout {
    $0.add([nameLabel, dateLabel])
    $0.addSpace(10)
    $0.add(messageLabel)
    $0.spacing = 5.0
  })

  $0.spacing = 15.0
  $0.padding(top: 15, left: 15, bottom: 15, right: 15)
  $0.debug = true
}

Hello World

Or you can use operand syntax for shorter/cleaner code:

let frameLayout = StackFrameLayout(axis: .horizontal)
frameLayout + VStackLayout {
	($0 + earthImageView).alignment = (.top, .center)
	($0 + 0).flexible() // add a flexible space
	($0 + rocketImageView).alignment = (.center, .center)
}
frameLayout + VStackLayout {
	$0 + [nameLabel, dateLabel] // add an array of views
	$0 + 10 // add space with 10 px fixed
	$0 + messageLabel // add a single view
	$0.spacing = 5.0 // spacing between views
}

frameLayout.spacing = 15.0
frameLayout.padding(top: 15, left: 15, bottom: 15, right: 15)
frameLayout.debug = true // show debug frame
}

Benchmark

FrameLayoutKit is one of the fastest layout libraries. Benchmark Results

See: Layout libraries benchmark's project

Todo

  • ☑ Swift Package Manager
  • ☑ CocoaPods support
  • ☑ Objective-C version (Deprecated - Not recommended)
  • ☑ Swift version
  • ☑ Examples
  • ☐ Documents

Author

Nam Kennic, namkennic@me.com

License

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

GitHub

link
Stars: 56
Last commit: 7 hours ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Release Notes

5.2.6
37 weeks ago

Fixed wrong layout for vertical bottom distribution

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics