Jamel  O'Reilly

Jamel O'Reilly

1659411360

AutoLayoutPlus: A bit of steroids for AutoLayout, powered by Swift

AutoLayoutPlus

AutoLayoutPlus is a Swift library consisting in a set of extensions to help dealing with Auto Layout programatically. With AutoLayoutPlus you don't need to change the way you've always worked with Auto Layout, it should feel as natural complement.

Keep reading for some more details on what's included (and have a look at the example provided)!

Features

  •  AutoLayoutPlus complements the existing UIKit methods to create constraints for your views.
  •  Helper methods for the most repetitive tasks (center view, apply the same constraint to multiple views, fill view horizontally, etc).
  •  Makes your code less verbose and easier to follow.
  •  No need to learn yet another DSL or library: AutoLayoutPlus feels natural and provides a similar experience to the methods you are already familiar with!

Extensions

AutoLayoutPlus works by adding some useful extensions to NSLayoutConstraint and UIView classes. To make use of those extensions don't forget to import AutoLayoutPlus into your code:

import AutoLayoutPlus

To help reducing the verbosity of the code, the multiplier and constant arguments have default values 1 and 0, respectively, so you won't have to specify them unless absolutely necessary.

NSLayoutConstraint extensions

convenience init(item view1: AnyObject, attribute attr1: NSLayoutAttribute, relatedBy relation: NSLayoutRelation, toItem view2: AnyObject?, attribute attr2: NSLayoutAttribute)

Usage:

// Old style
NSLayoutConstraint(item: centerBlueContainer, attribute: .CenterY, relatedBy: .Equal, toItem: view, attribute: .CenterY, multiplier: 1, constant: 0)

// AutoLayoutPlus style
NSLayoutConstraint(item: centerBlueContainer, attribute: .CenterY, relatedBy: .Equal, toItem: view, attribute: .CenterY)

class func withFormat(format: String, options: NSLayoutFormatOptions = NSLayoutFormatOptions(rawValue: 0), metrics: [String : AnyObject]? = nil, views: [String : AnyObject]) -> [NSLayoutConstraint]

Usage:

// Old style
NSLayoutConstraint.constraintsWithVisualFormat("V:|[topContainer(==60)]", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: views)

// AutoLayoutPlus style
NSLayoutConstraint.withFormat("V:|[topContainer(==60)]", views: views)

class func constraints(items views: [AnyObject], attribute attr1: NSLayoutAttribute, relatedBy relation: NSLayoutRelation, toItem view: AnyObject?, attribute attr2: NSLayoutAttribute, multiplier: CGFloat = 1, constant c: CGFloat = 0) -> [NSLayoutConstraint]

Usage:

// Old style
NSLayoutConstraint(item: centerBlueContainer, attribute: .CenterY, relatedBy: .Equal, toItem: view, attribute: .CenterY, multiplier: 1, constant: 0)
NSLayoutConstraint(item: centerGreenContainer, attribute: .CenterY, relatedBy: .Equal, toItem: view, attribute: .CenterY, multiplier: 1, constant: 0)
NSLayoutConstraint(item: centerOrangeContainer, attribute: .CenterY, relatedBy: .Equal, toItem: view, attribute: .CenterY, multiplier: 1, constant: 0)

// AutoLayoutPlus style
NSLayoutConstraint.constraints(items: [centerBlueContainer, centerGreenContainer, centerOrangeContainer], attribute: .CenterY, relatedBy: .Equal, toItem: view, attribute: .CenterY)

UIView extensions

func centeredInParent(multiplierX: CGFloat = 1, constantX: CGFloat = 0, multiplierY: CGFloat = 1, constantY: CGFloat = 0) -> [NSLayoutConstraint]
func centeredInView(view: UIView, multiplierX: CGFloat = 1, constantX: CGFloat = 0, multiplierY: CGFloat = 1, constantY: CGFloat = 0) -> [NSLayoutConstraint]

Usage:

// Old style
NSLayoutConstraint(item: centerBlueContainer, attribute: .CenterY, relatedBy: .Equal, toItem: view, attribute: .CenterY, multiplier: 1, constant: 0)
NSLayoutConstraint(item: centerBlueContainer, attribute: .CenterX, relatedBy: .Equal, toItem: view, attribute: .CenterX, multiplier: 1, constant: 0)
        
// AutoLayoutPlus style
centerBlueContainer. centeredInParent()

func centeredInParentY(multiplier: CGFloat = 1, constant: CGFloat = 0) -> NSLayoutConstraint
func centeredInParentX(multiplier: CGFloat = 1, constant: CGFloat = 0) -> NSLayoutConstraint
func centeredInViewY(view: UIView, multiplier: CGFloat = 1, constant: CGFloat = 0) -> NSLayoutConstraint
func centeredInViewX(view: UIView, multiplier: CGFloat = 1, constant: CGFloat = 0) -> NSLayoutConstraint

Usage:

// Old style
NSLayoutConstraint(item: centerBlueContainer, attribute: .CenterY, relatedBy: .Equal, toItem: view, attribute: .CenterY, multiplier: 1, constant: 0)
        
// AutoLayoutPlus style
centerBlueContainer. centeredInParentY()

func sameDimensionsAsParent(multiplier: CGFloat = 1, constant: CGFloat = 0) -> [NSLayoutConstraint]
func sameDimensionsAsView(view: UIView, multiplier: CGFloat = 1, constant: CGFloat = 0) -> [NSLayoutConstraint]

Usage:

// Old style
NSLayoutConstraint(item: centerBlueContainer, attribute: .Height, relatedBy: .Equal, toItem: view, attribute: .Height, multiplier: 1, constant: 0)
NSLayoutConstraint(item: centerBlueContainer, attribute: .Width, relatedBy: .Equal, toItem: view, attribute: .Width, multiplier: 1, constant: 0)
        
// AutoLayoutPlus style
centerBlueContainer. sameDimensionsAsParent()

func sameHeightAsParent(multiplier: CGFloat = 1, constant: CGFloat = 0) -> NSLayoutConstraint
func sameWidthAsParent(multiplier: CGFloat = 1, constant: CGFloat = 0) -> NSLayoutConstraint
func sameHeightAsView(view: UIView, multiplier: CGFloat = 1, constant: CGFloat = 0) -> NSLayoutConstraint
func sameWidthAsView(view: UIView, multiplier: CGFloat = 1, constant: CGFloat = 0) -> NSLayoutConstraint

Usage:

// Old style
NSLayoutConstraint(item: centerBlueContainer, attribute: .Height, relatedBy: .Equal, toItem: view, attribute: .Height, multiplier: 1, constant: 0)
        
// AutoLayoutPlus style
centerBlueContainer. sameHeightAsParent()

func likeParent() -> [NSLayoutConstraint]
func likeView(view: UIView) -> [NSLayoutConstraint]

Usage:

// Old style
NSLayoutConstraint(item: centerBlueContainer, attribute: .Height, relatedBy: .Equal, toItem: view, attribute: .Height, multiplier: 1, constant: 0)
NSLayoutConstraint(item: centerBlueContainer, attribute: .Width, relatedBy: .Equal, toItem: view, attribute: .Width, multiplier: 1, constant: 0)
NSLayoutConstraint(item: centerBlueContainer, attribute: .CenterY, relatedBy: .Equal, toItem: view, attribute: .CenterY, multiplier: 1, constant: 0)
NSLayoutConstraint(item: centerBlueContainer, attribute: .CenterX, relatedBy: .Equal, toItem: view, attribute: .CenterX, multiplier: 1, constant: 0)
     
// AutoLayoutPlus style
centerBlueContainer. likeParent()

Requirements

  • iOS 8.0+
  • Xcode 7.0+

Instalation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate AutoLayoutPlus into your Xcode project using CocoaPods, include this in your Podfile:

platform :ios, '8.0'
use_frameworks!

pod 'AutoLayoutPlus'

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate AutoLayoutPlus into your Xcode project using Carthage, specify it in your Cartfile:

github "ruipfcosta/AutoLayoutPlus" "master"

Run carthage to build the framework and drag the built AutoLayoutPlus.framework into your Xcode project.

Author: ruipfcosta
Source Code: https://github.com/ruipfcosta/AutoLayoutPlus
License: MIT license

#ios #swift 

What is GEEK

Buddha Community

AutoLayoutPlus: A bit of steroids for AutoLayout, powered by Swift
Houston  Sipes

Houston Sipes

1600430400

10 Free Online Resources To Learn Swift Language

Swift is a fast and efficient general-purpose programming language that provides real-time feedback and can be seamlessly incorporated into existing Objective-C code. This is why developers are able to write safer, more reliable code while saving time. It aims to be the best language that can be used for various purposes ranging from systems programming to mobile as well as desktop apps and scaling up to cloud services.

Below here, we list down the 10 best online resources to learn Swift language.

(The list is in no particular order)

#developers corner #free online resources to learn swift language #learn swift #learn swift free #learn swift online free #resources to learn swift #swift language #swift programming

Top Swift Development Companies | Top Swift Developers - TopDevelopers.co

A thoroughly researched list of top Swift developers with ratings & reviews to help find the best Swift development companies around the world.

#swift development service providers #best swift development companies #top swift development companies #swift development solutions #top swift developers #swift

Hire Dedicated Swift Developers

Want to create a native iOS application for your Startup?

Hire Dedicated Swift Developers for end-to-end services like development, migration, upgrade, testing, and support & maintenance. Trust HourlyDeveloper.io our Swift development team for iOS device apps that are high on performance and security.

Consult with experts:- https://bit.ly/2C5M6cz

#hire dedicated swift developers #swift developers #swift development company #swift development services #swift development #swift

sophia tondon

sophia tondon

1620885491

Microsoft Power BI Consulting | Power BI Solutions in India

Hire top dedicated Mirosoft power BI consultants from ValueCoders who aim at leveraging their potential to address organizational challenges for large-scale data storage and seamless processing.

We have a team of dedicated power BI consultants who help start-ups, SMEs, and enterprises to analyse business data and get useful insights.

What are you waiting for? Contact us now!

No Freelancers, 100% Own Staff
Experienced Consultants
Continuous Monitoring
Lean Processes, Agile Mindset
Non-Disclosure Agreement
Up To 2X Less Time

##power bi service #power bi consultant #power bi consultants #power bi consulting #power bi developer #power bi development

sophia tondon

sophia tondon

1619670565

Hire Power BI Developer | Microsoft Power BI consultants in India

Hire our expert Power BI consultants to make the most out of your business data. Our power bi developers have deep knowledge in Microsoft Power BI data modeling, structuring, and analysis. 16+ Yrs exp | 2500+ Clients| 450+ Team

Visit Website - https://www.valuecoders.com/hire-developers/hire-power-bi-developer-consultants

#power bi service #power bi consultant #power bi consultants #power bi consulting #power bi developer #power bi consulting services