UIView and CGRect extension that adds properties to manipulate them efficiently

Related tags

UI Geometry
Overview

Geometry

Build Status CocoaPods Compatible Carthage Compatible License Platform Twitter

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
  • centerY

And 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:

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:

github "artman/Geometry" ~> 3.0

Quick start

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:

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

License

Geometry is released under an MIT license. See the LICENSE file for more information

You might also like...
Simple battery shaped UIView
Simple battery shaped UIView

BatteryView Simple battery shaped UIView. Usage let batteryView = BatteryView(frame: smallRect) batteryView.level = 42 // anywhere in 0...100 batteryV

Elissa displays a notification on top of a UITabBarItem or any UIView anchor view to reveal additional information.
Elissa displays a notification on top of a UITabBarItem or any UIView anchor view to reveal additional information.

Elissa Attach a local notification to any UIView to reveal additional user guidance. Usage Example Per default, Elissa will try to align to the center

An iOS Library that makes shadows management easy on UIView.
An iOS Library that makes shadows management easy on UIView.

ShadowView is an iOS Shadow library that makes view's shadow implementation easy and sweet 🎉 🎊 . Add simple shadows to add a gaussian blurred projec

Custom Beautiful UIView For Handling IDs in iOS
Custom Beautiful UIView For Handling IDs in iOS

IDView Custom Beautiful UIView For Handling IDs in iOS Setup Set the placeholder images for the front and back faces. override func viewDidLoad()

A framework which helps you attach observers to `UIView`s to get updates on its frame changes

FrameObserver is a framework that lets you attach observers to any UIView subclass and get notified when its size changes. It doesn't use any Method S

Easily use UIKit views in your SwiftUI applications. Create Xcode Previews for UIView elements
Easily use UIKit views in your SwiftUI applications. Create Xcode Previews for UIView elements

SwiftUIKitView Easily use UIKit views in SwiftUI. Convert UIView to SwiftUI View Create Xcode Previews from UIView elements SwiftUI functional updatin

📹 Framework to Play a Video in the Background of any UIView
📹 Framework to Play a Video in the Background of any UIView

SwiftVideoBackground is an easy to use Swift framework that provides the ability to play a video on any UIView. This provides a beautiful UI for login

ScrollViewPlus is a small library that provides some helpful extension and capabilities for working with NSScrollView.

ScrollViewPlus is a small library that provides some helpful extension and capabilities for working with NSScrollView.

Safari Web Extension to customize your search engine.
Safari Web Extension to customize your search engine.

Safari Web Extension to customize your search engine. Search queries made from the Safari address bar are appended to the custom search engine URL. No

Comments
  • ambiguous use of height - xcode 7.3

    ambiguous use of height - xcode 7.3

    This was working the other day in my project - but after a clean / and reloading of pods - compiler errors are persisting. It maybe safer to use viewHeight / viewWidth

    screen shot 2016-06-06 at 8 36 24 am
    opened by johndpope 7
  • Correct the spelling of CocoaPods in README

    Correct the spelling of CocoaPods in README

    This pull requests corrects the spelling of CocoaPods 🤓 https://github.com/CocoaPods/shared_resources/tree/master/media

    Created with cocoapods-readme.

    opened by ReadmeCritic 1
Releases(3.0.0)
Owner
Tuomas Artman
Co-founder @ Linear. Previously staff engineer @ Uber
Tuomas Artman
NotSwiftUI is designed to help you create UI components quickly and efficiently with code!

NotSwiftUI NotSwiftUI is designed to help you create UI components quickly and efficiently with code! Capitalizing on the idea that most of the UI ele

Jonathan G. 50 Dec 20, 2022
A simple, customizable view for efficiently collecting country information in iOS apps.

CountryPickerView CountryPickerView is a simple, customizable view for selecting countries in iOS apps. You can clone/download the repository and run

Kizito Nwose 459 Dec 27, 2022
A library, which adds the ability to hide navigation bar when view controller is pushed via hidesNavigationBarWhenPushed flag

HidesNavigationBarWhenPushed A library, which adds the ability to hide navigation bar when view controller is pushed via hidesNavigationBarWhenPushed

Danil Gontovnik 55 Oct 19, 2022
A UITextView subclass that adds support for multiline placeholder written in Swift.

KMPlaceholderTextView A UITextView subclass that adds support for multiline placeholder written in Swift. Usage You can set the value of the placehold

Zhouqi Mo 794 Jan 7, 2023
SwiftUI-Margin adds a margin() viewModifier to a SwiftUI view.

SwiftUI-Margin adds a margin() viewModifier to a SwiftUI view. You will be able to layout the margins in a CSS/Flutter-like.

Masaaki Kakimoto(柿本匡章) 2 Jul 14, 2022
High performance and lightweight UIView, UIImage, UIImageView, UIlabel, UIButton, Promise and more.

SwiftyUI High performance and lightweight UIView, UIImage, UIImageView, UIlabel, UIButton and more. Features SwiftyView GPU rendering Image and Color

Haoking 336 Nov 26, 2022
Twinkle is a Swift and easy way to make any UIView in your iOS or tvOS app twinkle.

Twinkle ✨ Twinkle is a Swift and easy way to make any UIView in your iOS or tvOS app twinkle. This library creates several CAEmitterLayers and animate

patrick piemonte 600 Nov 24, 2022
Easily add drop shadows, borders, and round corners to a UIView.

Easily add drop shadows, borders, rounded corners to a UIView. Installation CocoaPods Add the follwing to your Podfile: pod 'Shades' Usage Storyboard

Aaron Sutton 14 Jun 20, 2020
Anchorage - Single file UIView drag and drop system

anchorage Single file UIView drag and drop system anchors.mp4 License Copyright

● ●●   ● 3 Jan 28, 2022
☠️ An elegant way to show users that something is happening and also prepare them to which contents they are awaiting

Features • Guides • Installation • Usage • Miscellaneous • Contributing ?? README is available in other languages: ???? . ???? . ???? . ???? . ???? To

Juanpe Catalán 11.7k Jan 6, 2023