explaingit

mamaral/neon

4,557SwiftAudience · developerComplexity · 2/5Setup · easy

TLDR

A Swift library for iOS that replaces verbose Auto Layout constraints with readable plain-English function calls like fillSuperview() or anchorInCorner(), making adaptive layouts shorter to write.

Mindmap

mindmap
  root((neon))
    What it does
      Position iOS views
      Replace constraints
      Adaptive layouts
    Key Functions
      fillSuperview
      anchorInCorner
      align relative
      groupAndFill
    Benefits
      Less code
      Readable syntax
      Screen adaptive
    Tech
      Swift
      iOS
      CocoaPods
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Replace verbose Auto Layout constraints with readable function calls like fillSuperview() or anchorInCorner() in an iOS app.

USE CASE 2

Arrange a row of buttons with equal spacing using a single groupAndFill() call.

USE CASE 3

Build adaptive layouts that automatically resize for different iPhone and iPad screen sizes and orientations.

USE CASE 4

Recreate complex screens like a Facebook profile layout in about ten lines of readable Swift code.

Tech stack

SwiftiOSCocoaPods

Getting it running

Difficulty · easy Time to first run · 30min

Add Neon via CocoaPods or drop source files into the project, targets iOS 9.0 and above.

In plain English

Neon is a Swift library for positioning UI elements in iOS apps without using Auto Layout constraints. In iOS development, placing views on screen typically involves either Auto Layout (which uses a constraint-based system that many developers find verbose and difficult to read) or the older springs-and-struts approach. Neon offers a third option: a set of plain-English functions that describe where a view should sit relative to its parent or sibling views. Instead of writing constraints, you call functions directly on a view. For example, fillSuperview() makes a view expand to fill its container. anchorInCorner(.BottomLeft...) places a view in the bottom-left corner with specified padding and size. align(.ToTheRightCentered, relativeTo: anotherView...) positions a view to the right of another view, vertically centered next to it. Groups of views can be arranged in horizontal or vertical rows with equal spacing using a single groupAndFill() call. The README demonstrates the approach by replicating the profile screen of the Facebook iOS app. The layout for the major visible components, including a banner image, avatar photo, name label, camera button, and four action buttons arranged in a row, is written in about ten lines of code. The result adapts to different device sizes and screen rotations without any extra work. Layouts built with Neon are dynamic: they recalculate positions based on the current screen size, so the same code works on an iPhone SE and an iPad in landscape mode. The README includes screenshots showing both portrait and landscape results from the Facebook demo. The library is installed via CocoaPods (a popular iOS dependency manager) or by dropping the source files directly into a project. It targets iOS 9.0 and above. The README notes that Swift 3.0 support was added but was still in beta at the time of writing.

Copy-paste prompts

Prompt 1
Show me how to use Neon to position a profile avatar in the bottom-left corner of a banner image in my iOS app.
Prompt 2
How do I arrange four action buttons in a horizontal row with equal spacing using Neon's groupAndFill method?
Prompt 3
I need a label positioned to the right of an image view, vertically centered. How do I do that with Neon?
Prompt 4
Walk me through installing Neon via CocoaPods and replicating the Facebook profile screen layout from the README.
Prompt 5
How does Neon automatically adapt my layout when the user rotates the device between portrait and landscape?
Open on GitHub → Explain another repo

← mamaral on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.