Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Material
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
Material
Commits
8db29285
Commit
8db29285
authored
Feb 11, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated project to Grid from GridView
parent
50d1b21d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
45 changed files
with
74 additions
and
51 deletions
+74
-51
Examples/Material.xcworkspace/contents.xcworkspacedata
+7
-7
Examples/Programmatic/Grid/Grid.xcodeproj/project.pbxproj
+0
-0
Examples/Programmatic/Grid/Grid.xcodeproj/project.xcworkspace/contents.xcworkspacedata
+1
-1
Examples/Programmatic/Grid/Grid/AppDelegate.swift
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/AppIcon.appiconset/Contents.json
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/AppIcon.appiconset/Material-Icon-29.png
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/AppIcon.appiconset/Material-Icon-29@2x-1.png
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/AppIcon.appiconset/Material-Icon-29@2x.png
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/AppIcon.appiconset/Material-Icon-29@3x.png
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/AppIcon.appiconset/Material-Icon-40.png
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/AppIcon.appiconset/Material-Icon-40@2x-1.png
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/AppIcon.appiconset/Material-Icon-40@2x.png
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/AppIcon.appiconset/Material-Icon-40@3x.png
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/AppIcon.appiconset/Material-Icon-60@2x.png
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/AppIcon.appiconset/Material-Icon-60@3x.png
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/AppIcon.appiconset/Material-Icon-76.png
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/AppIcon.appiconset/Material-Icon-76@2x.png
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/AppIcon.appiconset/Material-Icon-83.5@2x.png
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/Contents.json
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/CosmicMindInverted.imageset/Contents.json
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/CosmicMindInverted.imageset/CosmicMindInverted.png
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/ic_alarm_white.imageset/Contents.json
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/ic_alarm_white.imageset/ic_alarm_white.png
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/ic_alarm_white.imageset/ic_alarm_white_2x.png
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/ic_alarm_white.imageset/ic_alarm_white_3x.png
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/ic_flash_auto_white.imageset/Contents.json
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/ic_flash_auto_white.imageset/ic_flash_auto_white.png
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/ic_flash_auto_white.imageset/ic_flash_auto_white_2x.png
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/ic_flash_auto_white.imageset/ic_flash_auto_white_3x.png
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/ic_flash_off_white.imageset/Contents.json
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/ic_flash_off_white.imageset/ic_flash_off_white.png
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/ic_flash_off_white.imageset/ic_flash_off_white_2x.png
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/ic_flash_off_white.imageset/ic_flash_off_white_3x.png
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/ic_flash_on_white.imageset/Contents.json
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/ic_flash_on_white.imageset/ic_flash_on_white.png
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/ic_flash_on_white.imageset/ic_flash_on_white_2x.png
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/ic_flash_on_white.imageset/ic_flash_on_white_3x.png
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/ic_more_vert_white.imageset/Contents.json
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/ic_more_vert_white.imageset/ic_more_vert_white.png
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/ic_more_vert_white.imageset/ic_more_vert_white_2x.png
+0
-0
Examples/Programmatic/Grid/Grid/Assets.xcassets/ic_more_vert_white.imageset/ic_more_vert_white_3x.png
+0
-0
Examples/Programmatic/Grid/Grid/Base.lproj/LaunchScreen.storyboard
+0
-0
Examples/Programmatic/Grid/Grid/Info.plist
+0
-2
Examples/Programmatic/Grid/Grid/ViewController.swift
+13
-11
Sources/Grid.swift
+53
-30
No files found.
Examples/Material.xcworkspace/contents.xcworkspacedata
View file @
8db29285
...
...
@@ -16,6 +16,13 @@
</Group>
<Group
location =
"container:"
name =
"Grid"
>
<FileRef
location =
"group:Programmatic/Grid/Grid.xcodeproj"
>
</FileRef>
</Group>
<Group
location =
"container:"
name =
"MaterialLayer"
>
<FileRef
location =
"group:Programmatic/MaterialLayer/MaterialLayer.xcodeproj"
>
...
...
@@ -98,13 +105,6 @@
location =
"group:Programmatic/CaptureView/CaptureView.xcodeproj"
>
</FileRef>
</Group>
<Group
location =
"container:"
name =
"GridView"
>
<FileRef
location =
"group:Programmatic/GridView/GridView.xcodeproj"
>
</FileRef>
</Group>
</Group>
<Group
location =
"container:"
...
...
Examples/Programmatic/Grid
View/GridView
.xcodeproj/project.pbxproj
→
Examples/Programmatic/Grid
/Grid
.xcodeproj/project.pbxproj
View file @
8db29285
This diff is collapsed.
Click to expand it.
Examples/Programmatic/Grid
View/GridView
.xcodeproj/project.xcworkspace/contents.xcworkspacedata
→
Examples/Programmatic/Grid
/Grid
.xcodeproj/project.xcworkspace/contents.xcworkspacedata
View file @
8db29285
...
...
@@ -2,6 +2,6 @@
<Workspace
version =
"1.0"
>
<FileRef
location =
"self:Grid
View
.xcodeproj"
>
location =
"self:Grid.xcodeproj"
>
</FileRef>
</Workspace>
Examples/Programmatic/Grid
View/GridView
/AppDelegate.swift
→
Examples/Programmatic/Grid
/Grid
/AppDelegate.swift
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/AppIcon.appiconset/Contents.json
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/AppIcon.appiconset/Contents.json
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/AppIcon.appiconset/Material-Icon-29.png
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/AppIcon.appiconset/Material-Icon-29.png
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/AppIcon.appiconset/Material-Icon-29@2x-1.png
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/AppIcon.appiconset/Material-Icon-29@2x-1.png
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/AppIcon.appiconset/Material-Icon-29@2x.png
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/AppIcon.appiconset/Material-Icon-29@2x.png
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/AppIcon.appiconset/Material-Icon-29@3x.png
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/AppIcon.appiconset/Material-Icon-29@3x.png
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/AppIcon.appiconset/Material-Icon-40.png
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/AppIcon.appiconset/Material-Icon-40.png
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/AppIcon.appiconset/Material-Icon-40@2x-1.png
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/AppIcon.appiconset/Material-Icon-40@2x-1.png
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/AppIcon.appiconset/Material-Icon-40@2x.png
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/AppIcon.appiconset/Material-Icon-40@2x.png
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/AppIcon.appiconset/Material-Icon-40@3x.png
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/AppIcon.appiconset/Material-Icon-40@3x.png
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/AppIcon.appiconset/Material-Icon-60@2x.png
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/AppIcon.appiconset/Material-Icon-60@2x.png
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/AppIcon.appiconset/Material-Icon-60@3x.png
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/AppIcon.appiconset/Material-Icon-60@3x.png
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/AppIcon.appiconset/Material-Icon-76.png
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/AppIcon.appiconset/Material-Icon-76.png
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/AppIcon.appiconset/Material-Icon-76@2x.png
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/AppIcon.appiconset/Material-Icon-76@2x.png
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/AppIcon.appiconset/Material-Icon-83.5@2x.png
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/AppIcon.appiconset/Material-Icon-83.5@2x.png
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/Contents.json
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/Contents.json
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/CosmicMindInverted.imageset/Contents.json
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/CosmicMindInverted.imageset/Contents.json
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/CosmicMindInverted.imageset/CosmicMindInverted.png
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/CosmicMindInverted.imageset/CosmicMindInverted.png
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/ic_alarm_white.imageset/Contents.json
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/ic_alarm_white.imageset/Contents.json
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/ic_alarm_white.imageset/ic_alarm_white.png
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/ic_alarm_white.imageset/ic_alarm_white.png
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/ic_alarm_white.imageset/ic_alarm_white_2x.png
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/ic_alarm_white.imageset/ic_alarm_white_2x.png
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/ic_alarm_white.imageset/ic_alarm_white_3x.png
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/ic_alarm_white.imageset/ic_alarm_white_3x.png
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/ic_flash_auto_white.imageset/Contents.json
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/ic_flash_auto_white.imageset/Contents.json
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/ic_flash_auto_white.imageset/ic_flash_auto_white.png
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/ic_flash_auto_white.imageset/ic_flash_auto_white.png
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/ic_flash_auto_white.imageset/ic_flash_auto_white_2x.png
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/ic_flash_auto_white.imageset/ic_flash_auto_white_2x.png
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/ic_flash_auto_white.imageset/ic_flash_auto_white_3x.png
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/ic_flash_auto_white.imageset/ic_flash_auto_white_3x.png
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/ic_flash_off_white.imageset/Contents.json
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/ic_flash_off_white.imageset/Contents.json
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/ic_flash_off_white.imageset/ic_flash_off_white.png
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/ic_flash_off_white.imageset/ic_flash_off_white.png
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/ic_flash_off_white.imageset/ic_flash_off_white_2x.png
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/ic_flash_off_white.imageset/ic_flash_off_white_2x.png
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/ic_flash_off_white.imageset/ic_flash_off_white_3x.png
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/ic_flash_off_white.imageset/ic_flash_off_white_3x.png
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/ic_flash_on_white.imageset/Contents.json
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/ic_flash_on_white.imageset/Contents.json
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/ic_flash_on_white.imageset/ic_flash_on_white.png
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/ic_flash_on_white.imageset/ic_flash_on_white.png
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/ic_flash_on_white.imageset/ic_flash_on_white_2x.png
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/ic_flash_on_white.imageset/ic_flash_on_white_2x.png
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/ic_flash_on_white.imageset/ic_flash_on_white_3x.png
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/ic_flash_on_white.imageset/ic_flash_on_white_3x.png
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/ic_more_vert_white.imageset/Contents.json
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/ic_more_vert_white.imageset/Contents.json
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/ic_more_vert_white.imageset/ic_more_vert_white.png
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/ic_more_vert_white.imageset/ic_more_vert_white.png
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/ic_more_vert_white.imageset/ic_more_vert_white_2x.png
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/ic_more_vert_white.imageset/ic_more_vert_white_2x.png
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Assets.xcassets/ic_more_vert_white.imageset/ic_more_vert_white_3x.png
→
Examples/Programmatic/Grid
/Grid
/Assets.xcassets/ic_more_vert_white.imageset/ic_more_vert_white_3x.png
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Base.lproj/LaunchScreen.storyboard
→
Examples/Programmatic/Grid
/Grid
/Base.lproj/LaunchScreen.storyboard
View file @
8db29285
File moved
Examples/Programmatic/Grid
View/GridView
/Info.plist
→
Examples/Programmatic/Grid
/Grid
/Info.plist
View file @
8db29285
...
...
@@ -28,8 +28,6 @@
<
a
rr
a
y
>
<
string
>
armv7
<
/string
>
<
/
a
rr
a
y
>
<
k
e
y
>
UIStatusBarHidden
<
/k
e
y
>
<
fa
ls
e
/
>
<
k
e
y
>
UISupportedInterfaceOrientations
<
/k
e
y
>
<
a
rr
a
y
>
<
string
>
UIInterfaceOrientationPortrait
<
/string
>
...
...
Examples/Programmatic/Grid
View/GridView
/ViewController.swift
→
Examples/Programmatic/Grid
/Grid
/ViewController.swift
View file @
8db29285
...
...
@@ -29,7 +29,7 @@
*/
/**
The following ViewController demonstrates using Grid to make complex layouts.
*/
import
UIKit
...
...
@@ -40,10 +40,10 @@ class ViewController: UIViewController {
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
prepareView
()
// prepareHorizontalGridViewExample()
// prepareVerticalGridViewExample()
// prepareSmallCardViewExample()
// prepareMediumCardViewExample()
// prepareHorizontalGridViewExample()
// prepareVerticalGridViewExample()
// prepareSmallCardViewExample()
// prepareMediumCardViewExample()
prepareLargeCardViewExample
()
}
...
...
@@ -55,8 +55,8 @@ class ViewController: UIViewController {
/// Prepares the medium card example.
private
func
prepareLargeCardViewExample
()
{
let
cardView
:
MaterialPulseView
=
MaterialPulseView
(
frame
:
CGRectMake
(
16
,
100
,
view
.
bounds
.
width
-
32
,
35
0
))
cardView
.
pulseColor
=
MaterialColor
.
blueGrey
.
lighten5
let
cardView
:
MaterialPulseView
=
MaterialPulseView
(
frame
:
CGRectMake
(
16
,
100
,
view
.
bounds
.
width
-
32
,
40
0
))
cardView
.
pulseColor
=
MaterialColor
.
blueGrey
.
base
cardView
.
grid
.
axis
.
direction
=
.
Vertical
cardView
.
depth
=
.
Depth1
view
.
addSubview
(
cardView
)
...
...
@@ -65,6 +65,7 @@ class ViewController: UIViewController {
imageView
.
grid
.
rows
=
7
imageView
.
grid
.
columns
=
6
imageView
.
grid
.
spacing
=
4
imageView
.
backgroundColor
=
MaterialColor
.
clear
cardView
.
addSubview
(
imageView
)
var
image
:
UIImage
?
=
UIImage
(
named
:
"CosmicMindInverted"
)
...
...
@@ -78,6 +79,7 @@ class ViewController: UIViewController {
rightImageViewCollection
.
grid
.
columns
=
3
rightImageViewCollection
.
grid
.
axis
.
direction
=
.
Vertical
rightImageViewCollection
.
grid
.
spacing
=
4
rightImageViewCollection
.
backgroundColor
=
MaterialColor
.
clear
imageView
.
addSubview
(
rightImageViewCollection
)
image
=
UIImage
(
named
:
"CosmicMindInverted"
)
...
...
@@ -169,7 +171,7 @@ class ViewController: UIViewController {
/// Prepares the medium card example.
private
func
prepareMediumCardViewExample
()
{
let
cardView
:
MaterialPulseView
=
MaterialPulseView
(
frame
:
CGRectMake
(
16
,
100
,
view
.
bounds
.
width
-
32
,
240
))
cardView
.
pulseColor
=
MaterialColor
.
blueGrey
.
lighten5
cardView
.
pulseColor
=
MaterialColor
.
blueGrey
.
base
cardView
.
depth
=
.
Depth1
view
.
addSubview
(
cardView
)
...
...
@@ -254,7 +256,7 @@ class ViewController: UIViewController {
/// Prepares the small card example.
private
func
prepareSmallCardViewExample
()
{
let
cardView
:
MaterialPulseView
=
MaterialPulseView
(
frame
:
CGRectMake
(
16
,
100
,
view
.
bounds
.
width
-
32
,
152
))
cardView
.
pulseColor
=
MaterialColor
.
blueGrey
.
lighten5
cardView
.
pulseColor
=
MaterialColor
.
blueGrey
.
base
cardView
.
depth
=
.
Depth1
view
.
addSubview
(
cardView
)
...
...
@@ -378,7 +380,7 @@ class ViewController: UIViewController {
label2
.
text
=
"B"
label2
.
backgroundColor
=
MaterialColor
.
blue
.
base
// view.grid.columns = 9
// view.grid.columns = 9
view
.
grid
.
spacing
=
16
view
.
grid
.
contentInset
.
left
=
16
view
.
grid
.
contentInset
.
right
=
16
...
...
@@ -390,7 +392,7 @@ class ViewController: UIViewController {
print
(
v
.
frame
)
}
}
internal
func
handleButton
()
{
print
(
"Clicked Button"
)
}
...
...
Sources/Grid.swift
View file @
8db29285
...
...
@@ -59,6 +59,12 @@ public class GridAxis {
}
}
/**
Initializer.
- Parameter grid: The Grid reference used for offset values.
- Parameter rows: The number of rows, Vertical axis the grid will use.
- Parameter columns: The number of columns, Horizontal axis the grid will use.
*/
public
init
(
grid
:
Grid
,
rows
:
Int
=
12
,
columns
:
Int
=
12
)
{
self
.
grid
=
grid
self
.
rows
=
rows
...
...
@@ -84,6 +90,12 @@ public class GridOffset {
}
}
/**
Initializer.
- Parameter grid: The Grid reference used for offset values.
- Parameter rows: The number of rows, Vertical axis the grid will use.
- Parameter columns: The number of columns, Horizontal axis the grid will use.
*/
public
init
(
grid
:
Grid
,
rows
:
Int
=
0
,
columns
:
Int
=
0
)
{
self
.
grid
=
grid
self
.
rows
=
rows
...
...
@@ -140,6 +152,12 @@ public class Grid {
}
}
/**
Initializer.
- Parameter rows: The number of rows, Vertical axis the grid will use.
- Parameter columns: The number of columns, Horizontal axis the grid will use.
- Parameter spacing: The spacing between rows or columns.
*/
public
init
(
rows
:
Int
=
12
,
columns
:
Int
=
12
,
spacing
:
CGFloat
=
0
)
{
self
.
rows
=
rows
self
.
columns
=
columns
...
...
@@ -152,17 +170,14 @@ public class Grid {
public
func
reloadLayout
()
{
if
let
v
:
Array
<
UIView
>
=
views
{
var
n
:
Int
=
0
var
m
:
Int
=
0
for
var
i
:
Int
=
0
,
l
:
Int
=
v
.
count
-
1
;
i
<=
l
;
++
i
{
let
view
:
UIView
=
v
[
i
]
if
let
sv
:
UIView
=
view
.
superview
{
let
w
:
CGFloat
=
(
sv
.
bounds
.
width
-
contentInset
.
left
-
contentInset
.
right
+
spacing
)
/
CGFloat
(
axis
.
inherited
?
columns
:
axis
.
columns
)
let
h
:
CGFloat
=
(
sv
.
bounds
.
height
-
contentInset
.
top
-
contentInset
.
bottom
+
spacing
)
/
CGFloat
(
axis
.
inherited
?
rows
:
axis
.
rows
)
let
c
:
Int
=
view
.
grid
.
columns
let
r
:
Int
=
view
.
grid
.
rows
let
co
:
Int
=
view
.
grid
.
offset
.
columns
let
ro
:
Int
=
view
.
grid
.
offset
.
rows
sv
.
layoutIfNeeded
()
if
.
Horizontal
==
axis
.
direction
{
let
w
:
CGFloat
=
(
sv
.
bounds
.
width
-
contentInset
.
left
-
contentInset
.
right
+
spacing
)
/
CGFloat
(
axis
.
inherited
?
columns
:
axis
.
columns
)
let
c
:
Int
=
view
.
grid
.
columns
let
co
:
Int
=
view
.
grid
.
offset
.
columns
// View height.
let
vh
:
CGFloat
=
sv
.
bounds
.
height
-
contentInset
.
top
-
contentInset
.
bottom
...
...
@@ -173,34 +188,24 @@ public class Grid {
// View width.
let
vw
:
CGFloat
=
(
w
*
CGFloat
(
c
))
-
spacing
if
0
==
i
{
view
.
frame
=
CGRectMake
(
vl
,
contentInset
.
top
,
vw
,
vh
)
}
else
if
l
==
i
{
view
.
frame
=
CGRectMake
(
vl
,
contentInset
.
top
,
vw
,
vh
)
}
else
{
view
.
frame
=
CGRectMake
(
vl
,
contentInset
.
top
,
vw
,
vh
)
}
view
.
frame
=
CGRectMake
(
vl
,
contentInset
.
top
,
vw
,
vh
)
n
+=
c
+
co
-
1
}
else
if
.
Vertical
==
axis
.
direction
{
let
h
:
CGFloat
=
(
sv
.
bounds
.
height
-
contentInset
.
top
-
contentInset
.
bottom
+
spacing
)
/
CGFloat
(
axis
.
inherited
?
rows
:
axis
.
rows
)
let
r
:
Int
=
view
.
grid
.
rows
let
ro
:
Int
=
view
.
grid
.
offset
.
rows
// View width.
let
vw
:
CGFloat
=
sv
.
bounds
.
width
-
contentInset
.
left
-
contentInset
.
right
// View top.
let
vt
:
CGFloat
=
CGFloat
(
i
+
m
+
ro
)
*
h
+
contentInset
.
top
let
vt
:
CGFloat
=
CGFloat
(
i
+
n
+
ro
)
*
h
+
contentInset
.
top
// View height.
let
vh
:
CGFloat
=
(
h
*
CGFloat
(
r
))
-
spacing
if
0
==
i
{
view
.
frame
=
CGRectMake
(
contentInset
.
left
,
vt
,
vw
,
vh
)
}
else
if
l
==
i
{
view
.
frame
=
CGRectMake
(
contentInset
.
left
,
vt
,
vw
,
vh
)
}
else
{
view
.
frame
=
CGRectMake
(
contentInset
.
left
,
vt
,
vw
,
vh
)
}
m
+=
r
+
ro
-
1
view
.
frame
=
CGRectMake
(
contentInset
.
left
,
vt
,
vw
,
vh
)
n
+=
r
+
ro
-
1
}
}
}
...
...
@@ -208,31 +213,48 @@ public class Grid {
}
}
private
func
associatedObject
<
T
:
AnyObject
>
(
base
:
AnyObject
,
key
:
UnsafePointer
<
UInt8
>
,
initialiser
:
()
->
T
)
->
T
{
/**
Gets the Obj-C reference for the Grid object within the UIView extension.
- Parameter base: Base object.
- Parameter key: Memory key pointer.
- Parameter initializer: Object initializer.
- Returns: The associated reference for the initializer object.
*/
private
func
GridAssociatedObject
<
T
:
AnyObject
>
(
base
:
AnyObject
,
key
:
UnsafePointer
<
UInt8
>
,
initializer
:
()
->
T
)
->
T
{
if
let
associated
:
T
=
objc_getAssociatedObject
(
base
,
key
)
as?
T
{
return
associated
}
let
associated
=
initiali
s
er
()
let
associated
=
initiali
z
er
()
objc_setAssociatedObject
(
base
,
key
,
associated
,
.
OBJC_ASSOCIATION_RETAIN
)
return
associated
}
private
func
associateObject
<
T
:
AnyObject
>
(
base
:
AnyObject
,
key
:
UnsafePointer
<
UInt8
>
,
value
:
T
)
{
/**
Sets the Obj-C reference for the Grid object within the UIView extension.
- Parameter base: Base object.
- Parameter key: Memory key pointer.
- Parameter value: The object instance to set for the associated object.
- Returns: The associated reference for the initializer object.
*/
private
func
GridAssociateObject
<
T
:
AnyObject
>
(
base
:
AnyObject
,
key
:
UnsafePointer
<
UInt8
>
,
value
:
T
)
{
objc_setAssociatedObject
(
base
,
key
,
value
,
.
OBJC_ASSOCIATION_RETAIN
)
}
/// A memory reference to the Grid instance for UIView extensions.
private
var
gridKey
:
UInt8
=
0
/// Grid extension for UIView.
public
extension
UIView
{
/// Grid reference.
public
var
grid
:
Grid
{
get
{
return
a
ssociatedObject
(
self
,
key
:
&
gridKey
)
{
return
GridA
ssociatedObject
(
self
,
key
:
&
gridKey
)
{
return
Grid
()
}
}
set
(
value
)
{
a
ssociateObject
(
self
,
key
:
&
gridKey
,
value
:
value
)
GridA
ssociateObject
(
self
,
key
:
&
gridKey
,
value
:
value
)
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment