{"id":1304,"url":"https://github.com/AntonTheDev/FlightLayout","last_synced_at":"2025-08-02T04:30:49.732Z","repository":{"id":56911435,"uuid":"59678222","full_name":"AntonTheDev/FlightLayout","owner":"AntonTheDev","description":"An alternative layout framework, a balanced medium between manual layout and auto layout. Great for calculating frames with FlightAnimator!!","archived":false,"fork":false,"pushed_at":"2023-01-19T23:22:42.000Z","size":346,"stargazers_count":22,"open_issues_count":0,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-24T01:52:29.444Z","etag":null,"topics":["alignment","animation","ios","ios-swift","layout","swift","swift-framework","swift3","swiftlibrary","xcode-framework"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AntonTheDev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-25T16:10:43.000Z","updated_at":"2023-03-03T10:39:49.000Z","dependencies_parsed_at":"2023-02-11T22:30:27.194Z","dependency_job_id":null,"html_url":"https://github.com/AntonTheDev/FlightLayout","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntonTheDev%2FFlightLayout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntonTheDev%2FFlightLayout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntonTheDev%2FFlightLayout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntonTheDev%2FFlightLayout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AntonTheDev","download_url":"https://codeload.github.com/AntonTheDev/FlightLayout/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228438757,"owners_count":17920013,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alignment","animation","ios","ios-swift","layout","swift","swift-framework","swift3","swiftlibrary","xcode-framework"],"created_at":"2024-01-05T20:15:43.372Z","updated_at":"2024-12-06T08:30:41.697Z","avatar_url":"https://github.com/AntonTheDev.png","language":"Swift","funding_links":[],"categories":["Layout"],"sub_categories":["Other Hardware","Other free courses"],"readme":"# FlightLayout\n\n[![Cocoapods Compatible](https://img.shields.io/badge/pod-v0.8.1-blue.svg)]()\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)]()\n[![Platform](https://img.shields.io/badge/platform-ios%20%7C%20tvos-lightgrey.svg)]()\n[![License](https://img.shields.io/badge/license-MIT-343434.svg)]()\n[![Join the chat at https://gitter.im/AntonTheDev/FlightLayout](https://badges.gitter.im/AntonTheDev/FlightLayout.svg)](https://gitter.im/AntonTheDev/FlightLayout?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n![alt tag](/Documentation/FlightLayout.png?raw=true)\n## Introduction\n\nFlightLayout is a light weight, and easy to learn layout framework as an extension of the UIView. Functionally, it lives somewhere in between the manual process of laying out views from the old days, and the flexibility of Autolayout's dynamic constraint approach.\n\nSome use cases for this framework include the ability to animate views with core animation. Without the overhead of Autolayout's constraints system, we are free to apply animations without the hassle of disabling constraints to perform parametric animations to a layer's properties.\n\n## Demo\n\nSince the scope of the documentation is limited to a handful of examples, once you have finished with the reading the documentation below, feel free to clone the project and run the demo app with the project. The demo app provides the ability to pick different options in the method call, once selected, the app will align a demo view on the screen to it's final frame, and provide a code example to reflect it.\n\nAn example of how the view controller is laid out in the demo app is can be found [here](/Documentation/demo.md)\n\n## Installation\n\n* [Installation Documentation](/Documentation/installation.md)\n\n## Basic Use\n\nThe UIView Extension which contains the `align` method, when called by a view, the calling view will set it's own frame relatively as specified by the parameters in the method call . The method constraints 6 optional parameters with assigned defaults, thus creating very powerful and flexible method signature with lots of possibilities. See below for an in-depth examples below for definitions of each parameter.\n\nThere are two enumerators defined for horizontal and vertical alignment. These are the magic options that allow you to align the calling view relative to another frame.\n\n\u003cbr\u003e\n\n\n```swift   \nfunc align(toFrame frame    : CGRect? = nil,\n           withSize size    : CGSize? = nil,        \n           horizontal       : HorizontalAlign,  \n           vertical         : VerticalAlign,\n           horizontalOffset : CGFloat = 0.0,\n           verticalOffset   : CGFloat = 0.0)\n```\n\nWhen performing animations, there often comes a need to calculate the frame to perform an animation. The following method returns a pre-calculate the frame based on the method parameters included, without actually setting it on the calling view. The `align` method actually this to calculate it's final value.\n\n\n```swift\nfunc rectAligned(toFrame frame    : CGRect  = CGRectZero,\n                 withSize size    : CGSize? = nil,\n                 horizontal       : HorizontalAlign,\n                 vertical         : VerticalAlign,\n                 horizontalOffset : CGFloat = 0.0,\n                 verticalOffset   : CGFloat = 0.0) -\u003e CGRect\n```\n\n### Horizontal Alignment\n\nThe following horizontal options align the calling view on the horizontal plane, with illustrations below\n\n```swift\npublic enum HorizontalAlign {\n    case left           // Align horizontally to the Left\n    case leftEdge       // Align horizontally to the Left Edge\n    case center         // Align center.y horizontally\n    case rightEdge      // Align horizontally to the Right Edge\n    case right          // Align horizontally to the Right\n}\n\n```\n\n![alt tag](/Documentation/HorizontalAlignment.png?raw=true)\n\n### Vertical Alignment\n\nThe vertical options align the calling view on the vertical plane, with illustrations below\n\n\n```swift\npublic enum VerticalAlign {\n    case above          // Align vertically Above\n    case top            // Align vertically to the top\n    case center         // Align center.y vertically\n    case base           // Align vertically to the base\n    case below          // Align vertically Below\n}\n\n```\n\n![alt tag](/Documentation/VerticalAlignment.png?raw=true)\n\n\n##### Example 1\n\nIn the following example, first we add the a new view named **bigView** as a subview, and say you want to align it dead center relative to the superview's bounds. It's as calling align against the view with the following method. This call with align the big **bigView** against the view's bounds that it was added to, with a horizontal, and vertical, alignment of ``.center``.\n\n\n```swift\nview.addSubview(bigView)\n\nbigView.align(toFrame   : view.bounds,     \n   \t\t\t     withSize   : CGSize(width : 140.0, height : 140.0),        \n             horizontal : .center,  \n             vertical   : .center)\n```\n\nNote: In the case that the calculated frame is the same as the calling views frame, it will not actually set the frame on the caller, it will just exit. This helps avoid glitches during animations, i.e  setting the frame on the view that is currently animating, will flicker the view to it's final position.\n\n##### Example 2\n\nThe call in Example 1 can also be expressed by omitting **toFrame** parameter. In the absence of the **toFrame** parameter from the method call, the framework automatically assumes that you are intending to align the calling view against the it's superview's bounds.\n\n```swift\nview.addSubview(bigView)\n\nbigView.align(withSize   : CGSize(width : 140.0, height : 140.0),        \n              horizontal : .center,  \n              vertical   : .center)\n```\n\n##### Example 3\n\nWhat if we implemented a ``sizeToFit()`` method on our calling view.  In the absence of the **withSize** parameter from the method call, the framework automatically assumes that you are intending to use the current size of the calling view.\n\n```swift\nview.addSubview(bigView)\n\nbigView.sizeToFit()\nbigView.align(horizontal : .center,  \n              vertical   : .center)\n```\n\n###### Example 4\n\nThe above example, can also be expressed by omitting **horizontal** and **vertical** parameters. In the absence of the **horizontal** and **vertical** parameters from the method call, the framework automatically assumes that you are intending to align the calling view's to the center horizontally, and vertically, by defaulting to ``.Center``.\n\n\n```swift\nview.addSubview(bigView)\n\nbigView.sizeToFit()\nbigView.align()\n```\n\n### Horizontal \u0026 Vertical Offset\n\nThe **horizontalOffset** and **verticalOffset** parameters adjust the calling view's final frame on the **horizontal** and **vertical** alignment parameters.\n\nLets assume we want to center the view and adjust it 20px right, and 20px upward. We can do this by including the **horizontalOffset** and **verticalOffset** and update the offset as follows.\n\n\n```swift\nview.addSubview(bigView)\n\nbigView.sizeToFit()\nbigView.align(horizontal       : .center,  \n              vertical         : .center,\n              horizontalOffset : 20.0,\n              verticalOffset   : -20.0)\n```\n\n## License\n\u003cbr\u003e\n     The MIT License (MIT)  \n\n     Copyright (c) 2016 Anton Doudarev  \n\n     Permission is hereby granted, free of charge, to any person obtaining a copy\n     of this software and associated documentation files (the \"Software\"), to deal\n     in the Software without restriction, including without limitation the rights\n     to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n     copies of the Software, and to permit persons to whom the Software is\n     furnished to do so, subject to the following conditions:  \n\n     The above copyright notice and this permission notice shall be included in all\n     copies or substantial portions of the Software.  \n\n     THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n     IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n     FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n     AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n     LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n     SOFTWARE.  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAntonTheDev%2FFlightLayout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAntonTheDev%2FFlightLayout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAntonTheDev%2FFlightLayout/lists"}