Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/albertmontserrat/amgautolayouthelper
Autolayout extension for automatically adapt fonts on UI elements
https://github.com/albertmontserrat/amgautolayouthelper
Last synced: 2 months ago
JSON representation
Autolayout extension for automatically adapt fonts on UI elements
- Host: GitHub
- URL: https://github.com/albertmontserrat/amgautolayouthelper
- Owner: AlbertMontserrat
- License: mit
- Created: 2017-02-20T11:42:33.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-01T10:01:09.000Z (almost 7 years ago)
- Last Synced: 2024-10-10T10:20:20.618Z (3 months ago)
- Language: Swift
- Size: 37.1 KB
- Stars: 6
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AMGAutolayoutHelper
[![CI Status](http://img.shields.io/travis/Albert Montserrat/AMGAutolayoutHelper.svg?style=flat)](https://travis-ci.org/Albert Montserrat/AMGAutolayoutHelper)
[![Version](https://img.shields.io/cocoapods/v/AMGAutolayoutHelper.svg?style=flat)](http://cocoapods.org/pods/AMGAutolayoutHelper)
[![License](https://img.shields.io/cocoapods/l/AMGAutolayoutHelper.svg?style=flat)](http://cocoapods.org/pods/AMGAutolayoutHelper)
[![Platform](https://img.shields.io/cocoapods/p/AMGAutolayoutHelper.svg?style=flat)](http://cocoapods.org/pods/AMGAutolayoutHelper)## Example
To run the example project, clone the repo, and run `pod install` from the Example directory first.
## Requirements
## Installation
AMGAutolayoutHelper is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:```ruby
pod "AMGAutolayoutHelper"
```## How it works
AMGAutolayoutHelper works directly in interface builder. Just change the class of the UI elements (UILabel, UIButton, UITextField and UITextView) to the corresponding AMGAutolayout (AMGAutolayoutLabel, AMGAutolayoutButton, AMGAutolayoutField and AMGAutolayoutTextView).
This will make the font size adapt at screen width.If you prefer to adapt the font size at screen height, change the Axis name (@IBInspectable) from default (or 'horizontal') to 'vertical'
If you need to change it programmaticaly, you can get the calculations as follows:
```
let newSize = AMGAutolayoutHelper.shared.convertSize(size: 30.0)
let newSizeVertical = AMGAutolayoutHelper.shared.convertSize(size: 30.0, axis: .vertical)
let newSizeCustom = AMGAutolayoutHelper.shared.convertSize(size: 30.0, axis: .vertical, original: 500.0, final: 200.0)
```By default, the original screen size (the screen size designed) is iPhone 6 (375.0 x 667.0). If you want to change it, you can do it by setting:
```
AMGAutolayoutHelper.shared.defaultWidth = 375.0
AMGAutolayoutHelper.shared.defaultHeight = 667.0
```You can do it in application did finish launching.
## Author
Albert Montserrat, [email protected]
## License
AMGAutolayoutHelper is available under the MIT license. See the LICENSE file for more info.