mamaral / facade Goto Github PK
View Code? Open in Web Editor NEWProgrammatic view layout for the rest of us.
License: MIT License
Programmatic view layout for the rest of us.
License: MIT License
Is it possible to apply animations to a group as a whole, and/or apply an animation block to a group such that each view inside will use it?
Or all views should just be treated regularly?
https://github.com/Carthage/Carthage
Currently it says "Dependency "Facade" has no shared framework schemes", so we need create framework and share its schema.
Hello,
I'm using
self.imagerView = [UIImageView new];
self.imagerView.layer.cornerRadius = self.imagerView.frame.size.width / 2;
self.imagerView.clipsToBounds = YES;
[self.containerView addSubview:self.imagerView];
and
[self.imagerView anchorTopLeftWithLeftPadding:10 topPadding:10 width:50 height:50];
But UIimageView is not rounding as expected.
Please advise.
Hello,
Love your project. Can I use this category in a UITableViewCell?
Here's a SWIFT implementation!
It may need some optimization love, but should be 100% compliant to modern SWIFT libs.
(Anything Doubles Related needs looking into for perf sake at least.)
Swift Version Below:
//
// UIView.swift+(Facade)
// Copyright Go Nuts and Have Fun!
//
import Foundation
import UIKit
extension UIView {
func fCenter() -> CGPoint {
var center = CGPoint(x: self.frame.midX - self.frame.minX,y: self.frame.midY - self.frame.minY);
return center;
}
func xMin() -> CGFloat {
return CGRectGetMinX(self.frame)
}
func xMax() -> CGFloat {
return CGRectGetMaxX(self.frame)
}
func yMin() -> CGFloat {
return CGRectGetMinY(self.frame)
}
func yMax() -> CGFloat {
return CGRectGetMaxY(self.frame)
}
func width() -> CGFloat {
return CGRectGetWidth(self.frame)
}
func height() -> CGFloat {
return CGRectGetHeight(self.frame)
}
func fillSuperview() {
self.frame = CGRectMake(0, 0, CGRectGetWidth(self.superview!.frame), CGRectGetHeight(self.superview!.frame))
}
func anchorTopLeftWithLeftPadding(left: CGFloat, topPadding top: CGFloat, width: CGFloat, height: CGFloat) {
self.frame = CGRectMake(left, top, width, height)
}
func anchorTopRightWithRightPadding(right: CGFloat, topPadding top: CGFloat, width: CGFloat, height: CGFloat) {
self.frame = CGRectMake(CGRectGetWidth(self.superview!.frame) - width - right, top, width, height)
}
func anchorBottomLeftWithLeftPadding(left: CGFloat, bottomPadding bottom: CGFloat, width: CGFloat, height: CGFloat) {
self.frame = CGRectMake(left, CGRectGetHeight(self.superview!.frame) - height - bottom, width, height)
}
func anchorBottomRightWithRightPadding(right: CGFloat, bottomPadding bottom: CGFloat, width: CGFloat, height: CGFloat) {
self.frame = CGRectMake(CGRectGetWidth(self.superview!.frame) - width - right, CGRectGetHeight(self.superview!.frame) - height - bottom, width, height)
}
func anchorInCenterWithWidth(width: CGFloat, height: CGFloat) {
self.frame = CGRectMake((CGRectGetWidth(self.superview!.frame) / 2.0) - (width / 2.0), (CGRectGetHeight(self.superview!.frame) / 2.0) - (height / 2.0), width, height)
}
func anchorCenterLeftWithLeftPadding(left: CGFloat, width: CGFloat, height: CGFloat) {
self.frame = CGRectMake(left, (CGRectGetHeight(self.superview!.frame) / 2.0) - (height / 2.0), width, height)
}
func anchorCenterRightWithRightPadding(right: CGFloat, width: CGFloat, height: CGFloat) {
self.frame = CGRectMake(CGRectGetWidth(self.superview!.frame) - width - right, (CGRectGetHeight(self.superview!.frame) / 2.0) - (height / 2.0), width, height)
}
func anchorTopCenterWithTopPadding(top: CGFloat, width: CGFloat, height: CGFloat) {
self.frame = CGRectMake((CGRectGetWidth(self.superview!.frame) / 2.0) - (width / 2.0), top, width, height)
}
func anchorBottomCenterWithBottomPadding(bottom: CGFloat, width: CGFloat, height: CGFloat) {
self.frame = CGRectMake((CGRectGetWidth(self.superview!.frame) / 2.0) - (width / 2.0), CGRectGetHeight(self.superview!.frame) - height - bottom, width, height)
}
func anchorInCenterFillingWidthAndHeightWithLeftAndRightPadding(leftAndRight: CGFloat, topAndBottomPadding topAndBottom: CGFloat) {
self.frame = CGRectMake(leftAndRight, topAndBottom, CGRectGetWidth(self.superview!.frame) - (2 * leftAndRight), CGRectGetHeight(self.superview!.frame) - (2 * topAndBottom))
}
func anchorTopCenterFillingWidthWithLeftAndRightPadding(leftAndRight: CGFloat, topPadding top: CGFloat, height: CGFloat) {
self.frame = CGRectMake(leftAndRight, top, CGRectGetWidth(self.superview!.frame) - (2 * leftAndRight), height)
}
func anchorBottomCenterFillingWidthWithLeftAndRightPadding(leftAndRight: CGFloat, bottomPadding bottom: CGFloat, height: CGFloat) {
self.frame = CGRectMake(leftAndRight, CGRectGetHeight(self.superview!.frame) - height - bottom, CGRectGetWidth(self.superview!.frame) - (2 * leftAndRight), height)
}
func alignToTheRightOf(view: UIView, withLeftPadding left: CGFloat, topPadding top: CGFloat, width: CGFloat, height: CGFloat) {
self.frame = CGRectMake(CGRectGetMaxX(view.frame) + left, top, width, height)
}
func alignToTheRightOf(view: UIView, fillingWidthWithLeftAndRightPadding leftAndRight: CGFloat, topPadding top: CGFloat, height: CGFloat) {
self.frame = CGRectMake(CGRectGetMaxX(view.frame) + leftAndRight, top, CGRectGetWidth(self.superview!.frame) - CGRectGetMaxX(view.frame) - (2 * leftAndRight), height)
}
func alignToTheRightOf(view: UIView, matchingTopWithLeftPadding left: CGFloat, width: CGFloat, height: CGFloat) {
self.frame = CGRectMake(CGRectGetMaxX(view.frame) + left, CGRectGetMinY(view.frame), width, height)
}
func alignToTheRightOf(view: UIView, matchingTopAndFillingWidthWithLeftAndRightPadding leftAndRight: CGFloat, height: CGFloat) {
self.frame = CGRectMake(CGRectGetMaxX(view.frame) + leftAndRight, CGRectGetMinY(view.frame), CGRectGetWidth(view.superview!.frame) - CGRectGetMaxX(view.frame) - (2 * leftAndRight), height)
}
func alignToTheRightOf(view: UIView, matchingCenterWithLeftPadding left: CGFloat, width: CGFloat, height: CGFloat) {
self.frame = CGRectMake(CGRectGetMaxX(view.frame) + left, CGRectGetMidY(view.frame) - (height / 2.0), width, height)
}
func alignToTheRightOf(view: UIView, matchingCenterAndFillingWidthWithLeftAndRightPadding leftAndRight: CGFloat, height: CGFloat) {
self.frame = CGRectMake(CGRectGetMaxX(view.frame) + leftAndRight, CGRectGetMidY(view.frame) - (height / 2.0), CGRectGetWidth(view.superview!.frame) - CGRectGetMaxX(view.frame) - (2 * leftAndRight), height)
}
func alignToTheRightOf(view: UIView, matchingBottomWithLeftPadding left: CGFloat, width: CGFloat, height: CGFloat) {
self.frame = CGRectMake(CGRectGetMaxX(view.frame) + left, CGRectGetMaxY(view.frame) - height, width, height)
}
func alignToTheRightOf(view: UIView, matchingBottomAndFillingWidthWithLeftAndRightPadding leftAndRight: CGFloat, height: CGFloat) {
self.frame = CGRectMake(CGRectGetMaxX(view.frame) + leftAndRight, CGRectGetMaxY(view.frame) - height, CGRectGetWidth(view.superview!.frame) - CGRectGetMaxX(view.frame) - (2 * leftAndRight), height)
}
func alignToTheLeftOf(view: UIView, fillingWidthAndHeightWithLeftAndRightPadding leftAndRight: CGFloat, topAndBottomPadding topAndBottom: CGFloat) {
self.frame = CGRectMake(leftAndRight, topAndBottom, CGRectGetMinX(view.frame) - (2 * leftAndRight), CGRectGetHeight(self.superview!.frame) - (2 * topAndBottom))
}
func alignToTheLeftOf(view: UIView, matchingTopWithRightPadding right: CGFloat, width: CGFloat, height: CGFloat) {
self.frame = CGRectMake(CGRectGetMinX(view.frame) - width - right, CGRectGetMinY(view.frame), width, height)
}
func alignToTheLeftOf(view: UIView, matchingTopAndFillingWidthWithLeftAndRightPadding leftAndRight: CGFloat, height: CGFloat) {
self.frame = CGRectMake(leftAndRight, CGRectGetMinY(view.frame), CGRectGetMinX(view.frame) - (2 * leftAndRight), height)
}
func alignToTheLeftOf(view: UIView, matchingCenterWithRightPadding right: CGFloat, width: CGFloat, height: CGFloat) {
self.frame = CGRectMake(CGRectGetMinX(view.frame) - width - right, CGRectGetMidY(view.frame) - (height / 2.0), width, height)
}
func alignToTheLeftOf(view: UIView, matchingCenterAndFillingWidthWithLeftAndRightPadding leftAndRight: CGFloat, height: CGFloat) {
self.frame = CGRectMake(leftAndRight, CGRectGetMidY(view.frame) - (height / 2.0), CGRectGetMinX(view.frame) - (2 * leftAndRight), height)
}
func alignToTheLeftOf(view: UIView, matchingBottomWithRightPadding right: CGFloat, width: CGFloat, height: CGFloat) {
self.frame = CGRectMake(CGRectGetMinX(view.frame) - width - right, CGRectGetMaxY(view.frame) - height, width, height)
}
func alignToTheLeftOf(view: UIView, matchingBottomAndFillingWidthWithLeftAndRightPadding leftAndRight: CGFloat, height: CGFloat) {
self.frame = CGRectMake(leftAndRight, CGRectGetMaxY(view.frame) - height, CGRectGetMinX(view.frame) - (2 * leftAndRight), height)
}
func alignUnder(view: UIView, withLeftPadding left: CGFloat, topPadding top: CGFloat, width: CGFloat, height: CGFloat) {
self.frame = CGRectMake(left, CGRectGetMaxY(view.frame) + top, width, height)
}
func alignUnder(view: UIView, withRightPadding right: CGFloat, topPadding top: CGFloat, width: CGFloat, height: CGFloat) {
self.frame = CGRectMake(CGRectGetMaxX(self.superview!.frame) - width - right, CGRectGetMaxY(view.frame) + top, width, height)
}
func alignUnder(view: UIView, matchingLeftWithTopPadding top: CGFloat, width: CGFloat, height: CGFloat) {
self.frame = CGRectMake(CGRectGetMinX(view.frame), CGRectGetMaxY(view.frame) + top, width, height)
}
func alignUnder(view: UIView, matchingLeftAndFillingWidthWithRightPadding right: CGFloat, topPadding top: CGFloat, height: CGFloat) {
self.frame = CGRectMake(CGRectGetMinX(view.frame), CGRectGetMaxY(view.frame) + top, CGRectGetWidth(view.superview!.frame) - CGRectGetMinX(view.frame) - right, height)
}
func alignUnder(view: UIView, matchingCenterWithTopPadding top: CGFloat, width: CGFloat, height: CGFloat) {
self.frame = CGRectMake(CGRectGetMidX(view.frame) - (width / 2.0), CGRectGetMaxY(view.frame) + top, width, height)
}
func alignUnder(view: UIView, centeredFillingWidthWithLeftAndRightPadding leftAndRight: CGFloat, topPadding top: CGFloat, height: CGFloat) {
self.frame = CGRectMake(leftAndRight, CGRectGetMaxY(view.frame) + top, CGRectGetWidth(view.superview!.frame) - (2 * leftAndRight), height)
}
func alignUnder(view: UIView, centeredFillingWidthAndHeightWithLeftAndRightPadding leftAndRight: CGFloat, topAndBottomPadding topAndBottom: CGFloat) {
self.frame = CGRectMake(leftAndRight, CGRectGetMaxY(view.frame) + topAndBottom, CGRectGetWidth(view.superview!.frame) - (2 * leftAndRight), CGRectGetHeight(self.superview!.frame) - CGRectGetMaxY(view.frame) - topAndBottom - topAndBottom)
}
func alignUnder(view: UIView, matchingRightWithTopPadding top: CGFloat, width: CGFloat, height: CGFloat) {
self.frame = CGRectMake(CGRectGetMaxX(view.frame) - width, CGRectGetMaxY(view.frame) + top, width, height)
}
func alignUnder(view: UIView, matchingRightAndFillingWidthWithLeftPadding left: CGFloat, topPadding top: CGFloat, height: CGFloat) {
self.frame = CGRectMake(left, CGRectGetMaxY(view.frame) + top, CGRectGetMinX(view.frame) + CGRectGetWidth(view.frame) - left, height)
}
func alignUnder(view: UIView, matchingLeftAndRightFillingHeightWithTopPadding top: CGFloat, bottomPadding bottom: CGFloat) {
self.frame = CGRectMake(CGRectGetMinX(view.frame), CGRectGetMaxY(view.frame) + top, CGRectGetWidth(view.frame), CGRectGetHeight(self.superview!.frame) - CGRectGetMaxY(view.frame) - top - bottom)
}
func alignUnder(view: UIView, matchingLeftFillingWidthAndHeightWithRightPadding right: CGFloat, topPadding top: CGFloat, bottomPadding bottom: CGFloat) {
self.frame = CGRectMake(CGRectGetMinX(view.frame), CGRectGetMaxY(view.frame) + top, CGRectGetWidth(self.superview!.frame) - CGRectGetMinX(view.frame) - right, CGRectGetHeight(self.superview!.frame) - CGRectGetMaxY(view.frame) - top - bottom)
}
func alignAbove(view: UIView, matchingLeftWithBottomPadding bottom: CGFloat, width: CGFloat, height: CGFloat) {
self.frame = CGRectMake(CGRectGetMinX(view.frame), CGRectGetMinY(view.frame) - height - bottom, width, height)
}
func alignAbove(view: UIView, matchingLeftAndFillingWidthWithRightPadding right: CGFloat, bottomPadding bottom: CGFloat, height: CGFloat) {
self.frame = CGRectMake(CGRectGetMinX(view.frame), CGRectGetMinY(view.frame) - height - bottom, CGRectGetWidth(view.superview!.frame) - CGRectGetMinX(view.frame) - right, height)
}
func alignAbove(view: UIView, matchingCenterWithBottomPadding bottom: CGFloat, width: CGFloat, height: CGFloat) {
self.frame = CGRectMake(CGRectGetMidX(view.frame) - (width / 2.0), CGRectGetMinY(view.frame) - height - bottom, width, height)
}
func alignAbove(view: UIView, fillingWidthWithLeftAndRightPadding leftAndRight: CGFloat, bottomPadding bottom: CGFloat, height: CGFloat) {
self.frame = CGRectMake(leftAndRight, CGRectGetMinY(view.frame) - height - bottom, CGRectGetWidth(view.superview!.frame) - (2 * leftAndRight), height)
}
func alignAbove(view: UIView, matchingRightWithBottomPadding bottom: CGFloat, width: CGFloat, height: CGFloat) {
self.frame = CGRectMake(CGRectGetMaxX(view.frame) - width, CGRectGetMinY(view.frame) - height - bottom, width, height)
}
func alignAbove(view: UIView, matchingRightAndFillingWidthWithLeftPadding left: CGFloat, bottomPadding bottom: CGFloat, height: CGFloat) {
self.frame = CGRectMake(left, CGRectGetMinY(view.frame) - height - bottom, CGRectGetMinX(view.frame) + CGRectGetWidth(view.frame) - left, height)
}
func alignBetweenLeft(leftView: UIView, andRight rightView: UIView, matchingTopWithLeftAndRightPadding leftAndRight: CGFloat, height: CGFloat) {
var xOrigin: CGFloat = CGRectGetMaxX(leftView.frame) + leftAndRight
self.frame = CGRectMake(xOrigin, CGRectGetMinY(leftView.frame), CGRectGetWidth(self.superview!.frame) - xOrigin - (CGRectGetWidth(self.superview!.frame) - CGRectGetMinX(rightView.frame)) - leftAndRight, height)
}
func alignBetweenLeft(leftView: UIView, andRight rightView: UIView, matchingCenterWithLeftAndRightPadding leftAndRight: CGFloat, height: CGFloat) {
var xOrigin: CGFloat = CGRectGetMaxX(leftView.frame) + leftAndRight
self.frame = CGRectMake(xOrigin, CGRectGetMidY(leftView.frame) - (height / 2.0), CGRectGetWidth(self.superview!.frame) - xOrigin - (CGRectGetWidth(self.superview!.frame) - CGRectGetMinX(rightView.frame)) - leftAndRight, height)
}
func alignBetweenTop(topView: UIView, andBottom bottomView: UIView, matchingLeftWithTopAndBottomPadding topAndBottom: CGFloat, width: CGFloat) {
var yOrigin: CGFloat = CGRectGetMaxY(topView.frame) + topAndBottom
self.frame = CGRectMake(CGRectGetMinX(topView.frame), CGRectGetMaxY(topView.frame) + topAndBottom, width, CGRectGetHeight(self.superview!.frame) - yOrigin - (CGRectGetHeight(self.superview!.frame) - CGRectGetMinY(bottomView.frame)) - topAndBottom)
}
func alignBetweenTop(topView: UIView, andBottom bottomView: UIView, centeredWithLeftAndRightPadding leftAndRight: CGFloat, topAndBottomPadding topAndBottom: CGFloat) {
self.frame = CGRectMake(leftAndRight, CGRectGetMaxY(topView.frame) + topAndBottom, CGRectGetWidth(self.superview!.frame) - (2 * leftAndRight), CGRectGetMinY(bottomView.frame) - CGRectGetMaxY(topView.frame) - (2 * topAndBottom))
}
//Mark: Anything Referencing Doubles Below is My Stupid Fixes. Not required, and likely needing optimization.
func groupHorizontally(views: [UIView], centeredUnderView view: UIView, topPadding top: CGFloat, spacing: CGFloat, width: CGFloat, height: CGFloat) {
var space:Double = Double(spacing);
var count:Double = Double(views.count);
var frameWidth:Double = Double(CGRectGetWidth(self.frame));
var maxWidth = Double(count) * Double(width);
var xO: Double = (frameWidth - (maxWidth) - ((count - 1) * space)) / 2.0
var xOrigin:CGFloat = CGFloat(xO);
for subview: UIView in views {
subview.frame = CGRectMake(xOrigin, CGRectGetMaxY(view.frame) + top, width, height)
xOrigin += width + spacing
}
}
func groupHorizontally(subviews: [UIView], fillingWidthAndHeightWithTopAndBottomPadding topAndBottom: CGFloat, spacing: CGFloat) {
var top:Double = Double(topAndBottom);
var space:Double = Double(spacing);
var subviewCount:Double = Double(subviews.count)
var frameWidth:Double = Double(CGRectGetWidth(self.frame));
var frameHeight:Double = Double(CGRectGetHeight(self.frame));
var w: Double = (frameWidth - ((subviewCount + 1) * space)) / subviewCount
var h: Double = frameHeight - (2 * top)
var xOrigin: CGFloat = spacing
var width:CGFloat = CGFloat(w);
var height:CGFloat = CGFloat(h);
for subview: UIView in subviews {
subview.frame = CGRectMake(xOrigin, topAndBottom, width, height)
xOrigin += width + spacing
}
}
func groupHorizontally(views: [UIView], fillingHeightWithLeftPadding left: CGFloat, spacing: CGFloat, topAndBottomPadding topAndBottom: CGFloat, width: CGFloat) {
var xOrigin: CGFloat = left
var height: CGFloat = CGRectGetHeight(self.frame) - (2 * topAndBottom)
for subview: UIView in views {
subview.frame = CGRectMake(xOrigin, topAndBottom, width, height)
xOrigin += width + spacing
}
}
func groupVertically(subviews: [UIView], inUpperRightWithRightPadding right: CGFloat, topPadding top: CGFloat, spacing: CGFloat, width: CGFloat, height: CGFloat) {
var yOrigin: CGFloat = top
for view: UIView in subviews {
view.frame = CGRectMake(CGRectGetWidth(self.frame) - width - right, yOrigin, width, height)
yOrigin += height + spacing
}
}
func groupVertically(subviews: [UIView], centerRightWithRightPadding right: CGFloat, spacing: CGFloat, width: CGFloat, height: CGFloat) {
var frameHeight:Double = Double(CGRectGetHeight(self.frame));
var count = Double(subviews.count);
var h:Double = Double(height);
var maxHeight:Double = Double(count * h);
var space:Double = Double(spacing);
var yO:Double = (frameHeight - (maxHeight) - ((count - 1) * space)) / 2.0
var yOrigin: CGFloat = CGFloat(yO);
for view: UIView in subviews {
view.frame = CGRectMake(CGRectGetWidth(self.frame) - width - right, yOrigin, width, height)
yOrigin += height + spacing
}
}
func groupVertically(subviews: [UIView], inLowerRightWithRightPadding right: CGFloat, bottomPadding bottom: CGFloat, spacing: CGFloat, width: CGFloat, height: CGFloat) {
var h:Double = Double(height);
var b:Double = Double(bottom);
var frameHeight:Double = Double(CGRectGetHeight(self.frame));
var yO:Double = Double(frameHeight - h - b);
var yOrigin: CGFloat = CGFloat(yO);
for view: UIView in subviews {
view.frame = CGRectMake(CGRectGetWidth(self.frame) - width - right, yOrigin, width, height)
yOrigin -= height + spacing
}
}
func groupVertically(subviews: [UIView], inUpperLeftWithLeftPadding left: CGFloat, topPadding top: CGFloat, spacing: CGFloat, width: CGFloat, height: CGFloat) {
var yOrigin: CGFloat = top
for view: UIView in subviews {
view.frame = CGRectMake(left, yOrigin, width, height)
yOrigin += height + spacing
}
}
func groupVertically(subviews: [UIView], centerLeftWithLeftPadding left: CGFloat, spacing: CGFloat, width: CGFloat, height: CGFloat) {
var frameHeight:Double = Double(CGRectGetHeight(self.frame));
var count:Double = Double(subviews.count);
var h:Double = Double(height);
var maxHeight:Double = Double(count * h);
var space:Double = Double(spacing);
var yO:Double = (frameHeight - (maxHeight) - ((count - 1) * space)) / 2.0
var yOrigin: CGFloat = CGFloat(yO);
for view: UIView in subviews {
view.frame = CGRectMake(left, yOrigin, width, height)
yOrigin += height + spacing
}
}
func groupVertically(subviews: [UIView], inLowerLeftWithLeftPadding left: CGFloat, bottomPadding bottom: CGFloat, spacing: CGFloat, width: CGFloat, height: CGFloat) {
var yOrigin: CGFloat = CGRectGetHeight(self.frame) - height - bottom
for view: UIView in subviews {
view.frame = CGRectMake(left, yOrigin, width, height)
yOrigin -= height + spacing
}
}
func groupVertically(subviews: [UIView], topCenterWithTopPadding top: CGFloat, spacing: CGFloat, width: CGFloat, height: CGFloat) {
var yOrigin: CGFloat = top
for view: UIView in subviews {
view.frame = CGRectMake((CGRectGetWidth(self.frame) / 2.0) - (width / 2.0), yOrigin, width, height)
yOrigin += height + spacing
}
}
func groupVertically(subviews: [UIView], centerWithSpacing spacing: CGFloat, width: CGFloat, height: CGFloat) {
var frameHeight:Double = Double(CGRectGetHeight(self.frame));
var count:Double = Double(subviews.count);
var h: Double = Double(height);
var maxHeight:Double = Double(count * h);
var space:Double = Double(spacing);
var yO:Double = Double((frameHeight - (maxHeight) - ((count - 1) * space)) / 2.0)
var yOrigin: CGFloat = CGFloat(yO);
for view: UIView in subviews {
view.frame = CGRectMake((CGRectGetWidth(self.frame) / 2.0) - (width / 2.0), yOrigin, width, height)
yOrigin += height + spacing
}
}
func groupVertically(subviews: [UIView], bottomCenterWithBottomPadding bottom: CGFloat, spacing: CGFloat, width: CGFloat, height: CGFloat) {
var yOrigin: CGFloat = CGRectGetHeight(self.frame) - height - bottom
for view: UIView in subviews {
view.frame = CGRectMake((CGRectGetWidth(self.frame) / 2.0) - (width / 2.0), yOrigin, width, height)
yOrigin -= height + spacing
}
}
func groupGrid(subviews: [UIView], fillingWidthWithColumnCount columnCount: UInt, spacing: CGFloat) {
var currentColumn: UInt = 0
var xOrigin: CGFloat = spacing
var yOrigin: CGFloat = spacing
var frameWidth:Double = Double(CGRectGetWidth(self.frame));
var count:Double = Double(columnCount);
var space:Double = Double(spacing);
var s:Double = Double((frameWidth - ((count + 1) * space) / count));
var size: CGFloat = CGFloat(s);
var offset: CGFloat = size + spacing
for subview: UIView in subviews {
subview.frame = CGRectMake(xOrigin, yOrigin, size, size)
if currentColumn == columnCount - 1 {
currentColumn = 0
xOrigin = spacing
yOrigin += offset
}
else {
currentColumn++
xOrigin += offset
}
}
}
}
Hey @mamaral
how are you? I just stumbled upon your Project and it looks really cool. But Apple announced UIStackView
and i am asking myself what the advantage is, using Facaded in comparisson to Apples Solution.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.