All Projects → freak4pc → Uiview Positioning

freak4pc / Uiview Positioning

Licence: mit
Easy property-based setting of frame properties in UIView objects

Programming Languages

swift
15916 projects
swift3
66 projects

Projects that are alternatives of or similar to Uiview Positioning

Bilibili Helper O
哔哩哔哩 (bilibili.com) 辅助工具,可以替换播放器、推送通知并进行一些快捷操作
Stars: ✭ 3,717 (+797.83%)
Mutual labels:  extension
Roam Toolkit
Roam force multiplier
Stars: ✭ 390 (-5.8%)
Mutual labels:  extension
Handyswift
Handy Swift features that didn't make it into the Swift standard library.
Stars: ✭ 403 (-2.66%)
Mutual labels:  extension
Openvsx
An open-source registry for VS Code extensions
Stars: ✭ 344 (-16.91%)
Mutual labels:  extension
Hyperjson
A hyper-fast Python module for reading/writing JSON data using Rust's serde-json.
Stars: ✭ 374 (-9.66%)
Mutual labels:  extension
Amvim For Vscode
The Vim mode for Visual Studio Code(vscode) that works as expected.
Stars: ✭ 393 (-5.07%)
Mutual labels:  extension
Vue Designer
Vue component design tool
Stars: ✭ 333 (-19.57%)
Mutual labels:  extension
Fontisto
The iconic font and CSS toolkit. Fontisto gives you scalable vector icons that can instantly be customized: size, color, drop shadow and anything that can be done with the power of CSS.
Stars: ✭ 413 (-0.24%)
Mutual labels:  extension
Textext
Re-editable LaTeX graphics for Inkscape
Stars: ✭ 383 (-7.49%)
Mutual labels:  extension
Swiftuikitview
Easily use UIKit views in your SwiftUI applications. Create Xcode Previews for UIView elements
Stars: ✭ 398 (-3.86%)
Mutual labels:  uiview
Epub Press Clients
📦 Clients for building books with EpubPress.
Stars: ✭ 370 (-10.63%)
Mutual labels:  extension
Bracketpair
Bracket Colorizer Extension for VSCode
Stars: ✭ 374 (-9.66%)
Mutual labels:  extension
Nakplaybackindicatorview
A UIView that mimics the music playback indicator in the Music.app on iOS 7+
Stars: ✭ 394 (-4.83%)
Mutual labels:  uiview
Easyswiftlayout
Lightweight Swift framework for Apple's Auto-Layout
Stars: ✭ 345 (-16.67%)
Mutual labels:  uiview
1click Webpage Screenshot
Entire page Screenshot extension for Google Chrome. I'm developing open source extension for Google Chrome. All extension are free for use. Let's make Chrome great again!
Stars: ✭ 406 (-1.93%)
Mutual labels:  extension
Surfingkeys
Map your keys for web surfing, expand your browser with javascript and keyboard.
Stars: ✭ 3,787 (+814.73%)
Mutual labels:  extension
Shadowview
An iOS Library that makes shadows management easy on UIView.
Stars: ✭ 391 (-5.56%)
Mutual labels:  uiview
Bs Detector
🚨 THIS REPOSITORY HAS MOVED. 🚨
Stars: ✭ 414 (+0%)
Mutual labels:  extension
Github Dark Theme
GitHub Dark Theme - Extension for Chrome, Firefox, and Microsoft Edge
Stars: ✭ 413 (-0.24%)
Mutual labels:  extension
Tamperchrome
Tamper Dev is an extension that allows you to intercept and edit HTTP/HTTPS requests and responses as they happen without the need of a proxy. Works across all operating systems (including Chrome OS).
Stars: ✭ 3,968 (+858.45%)
Mutual labels:  extension

UIView-Positioning

UIView+Positioning is a Swift Extension which provides easy shorthand methods to defining the frame properties (width, height, x, y) of any UIView based object in an easy fashion, as well as extra helpful properties and methods.

USAGE

Just use the properties x, y, width, height or use origin and size to kill two birds with one stone ;-)

let btnTest     = UIButton()        // Or any other view

btnTest.width   = 250
btnTest.height  = 100

btnTest.y      -= 100
btnTest.x      += 35

btnTest.centerX = 20
btnTest.centerY = 15

btnTest.size    = CGSize(width: 150, height: 70)
btnTest.origin  = CGPoint(x: 25, y: 10)

print(btnTest.lastSubviewOnX?.x)  // X value of the object with the largest X value
print(btnTest.lastSubviewOnY?.y)  // Y value of the object with the largest Y value

btnTest.centerToParent()          // Centers button to its parent view, if exists

Here's another short example of using centerToParent and the Fibonacci Series to create multiple subviewed squares

var currentView                 = self.view
var currentSize: CGFloat        = 300

for i in 0...12 {
    let newView                 = UIView()
    newView.size                = CGSize(width: currentSize, height: currentSize)
    newView.backgroundColor     = UIColor.random
    currentView?.addSubview(newView)
    newView.centerToParent()

    currentView                 = newView
    currentSize                -= CGFloat(self.fibonacci(i+6) / 10)
}

Will result in this:

Fibonacci Views

AVAILABLE PROPERTIES & METHODS

  • x, y, origin - Positioning Shorthand

  • width, height, size - Sizing Shorthand

  • left, bottom, top, right - Representing X and Y values of the different sides of the view

  • centerX, centerY - Shorthand for the X and Y of the View's Center

  • boundsWidth, boundsHeight - Shorthand for the width and height of the View's bounds

  • boundsX, boundsY - Shorthand for the X and Y position of the View's bounds

  • lastSubviewOnX, lastSubviewOnY - Returns the Subview with the height X or Y value (closest to the right or closest to the bottom)

  • centerToParent - Center the current view relatively to his superview, if one exists

INSTALLATION

Add the following line to your Podfile:

pod 'UIView+Positioning'

and then run:

$ pod install

PORTS

LICENSE

Copyright (C) 2013 Developed by Shai Mishali

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].