Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/artman/Geometry
UIView and CGRect extension that adds properties to manipulate them efficiently
https://github.com/artman/Geometry
Last synced: 4 months ago
JSON representation
UIView and CGRect extension that adds properties to manipulate them efficiently
- Host: GitHub
- URL: https://github.com/artman/Geometry
- Owner: artman
- License: mit
- Created: 2014-09-09T04:25:59.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-11-03T03:47:17.000Z (over 7 years ago)
- Last Synced: 2024-10-12T00:21:45.138Z (4 months ago)
- Language: Swift
- Size: 35.2 KB
- Stars: 91
- Watchers: 5
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-swift-cn - Geometry - extensions for UIView. (Libs / UI)
- awesome-swift - Geometry - extensions for UIView. (Libs / UI)
- awesome-swift - Geometry - UIView and CGRect extension that adds properties to manipulate them efficiently ` 📝 5 years ago ` (UI [🔝](#readme))
README
# Geometry
[](https://travis-ci.org/artman/Geometry)
[](https://cocoapods.org/pods/Geometry)
[](https://github.com/Carthage/Carthage)


[](http://twitter.com/artman)Geometry is a UIView and CGRect extension that lets you work with view and rect geometry easier. It adds the following properties to UIView:
* top
* left
* bottom
* right
* width
* height
* centerX
* centerYAnd it lets you define CGRectangles and CGPoints as strings.
## Requirements
- iOS 7.0 / watchOS 2.0 / Mac OS X 10.9
- Swift 3.0## Installation
To use Signals with a project targeting iOS 7, copy `Geometry.swift` into your project.
#### CocoaPods
To integrate Geometry into your project add the following to your `Podfile`:
```ruby
platform :ios, '8.0'
use_frameworks!pod 'Geometry', '~> 3.0'
```#### Carthage
To integrate Geometry into your project using Carthage add the following to your `Cartfile`:
```ruby
github "artman/Geometry" ~> 3.0
```## Quick start
```Swift
myView.frame = CGRect(x: 10, y: 10, width: 20, height: 20)
myView.left = 20 // Frame is now {{20, 10}, {20, 20}}
myView.width = 100 // Frame is now {{20, 10}, {100, 20}}
myView.right = 150 // Frame is now {{50, 10}, {100, 20}}
```This extension also provides StringLiteralConverters for both CGRect and CGPoint, so you can use Strings to initialize a CGRect:
```Swift
myView.frame = "10, 10, 20, 20"
myView.center = "50, 50"
var rect: CGRect = "20, 25, 100, 100"
```## Contribute
To contribute, just fork, branch & send a pull request. To get in touch, hit me up on Twitter [@artman](http://twitter.com/artman)
## License
Geometry is released under an MIT license. See the LICENSE file for more information