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
365cba14
Unverified
Commit
365cba14
authored
Jun 25, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: added convenience to CollectionView
parent
ca7be84e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
6 deletions
+31
-6
Sources/iOS/CollectionView.swift
+10
-3
Sources/iOS/CollectionViewController.swift
+14
-1
Sources/iOS/NavigationController.swift
+7
-2
No files found.
Sources/iOS/CollectionView.swift
View file @
365cba14
...
@@ -99,14 +99,21 @@ open class CollectionView: UICollectionView {
...
@@ -99,14 +99,21 @@ open class CollectionView: UICollectionView {
super
.
init
(
frame
:
frame
,
collectionViewLayout
:
layout
)
super
.
init
(
frame
:
frame
,
collectionViewLayout
:
layout
)
prepare
()
prepare
()
}
}
/**
An initializer that initializes the object.
- Parameter collectionViewLayout: A UICollectionViewLayout reference.
*/
public
convenience
init
(
collectionViewLayout
layout
:
UICollectionViewLayout
)
{
self
.
init
(
frame
:
.
zero
,
collectionViewLayout
:
layout
)
}
/**
/**
An initializer that initializes the object.
An initializer that initializes the object.
- Parameter frame: A CGRect defining the view's frame.
- Parameter frame: A CGRect defining the view's frame.
*/
*/
public
init
(
frame
:
CGRect
)
{
public
convenience
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
,
collectionViewLayout
:
CollectionViewLayout
())
self
.
init
(
frame
:
frame
,
collectionViewLayout
:
CollectionViewLayout
())
prepare
()
}
}
/// A convenience initializer that initializes the object.
/// A convenience initializer that initializes the object.
...
...
Sources/iOS/CollectionViewController.swift
View file @
365cba14
...
@@ -71,7 +71,7 @@ open class CollectionViewController: UIViewController {
...
@@ -71,7 +71,7 @@ open class CollectionViewController: UIViewController {
open
override
func
viewWillLayoutSubviews
()
{
open
override
func
viewWillLayoutSubviews
()
{
super
.
viewWillLayoutSubviews
()
super
.
viewWillLayoutSubviews
()
collectionView
.
frame
=
view
.
bounds
layoutSubviews
()
}
}
/**
/**
...
@@ -87,6 +87,11 @@ open class CollectionViewController: UIViewController {
...
@@ -87,6 +87,11 @@ open class CollectionViewController: UIViewController {
view
.
contentScaleFactor
=
Screen
.
scale
view
.
contentScaleFactor
=
Screen
.
scale
prepareCollectionView
()
prepareCollectionView
()
}
}
/// Calls the layout functions for the view heirarchy.
open
func
layoutSubviews
()
{
layoutCollectionView
()
}
}
}
extension
CollectionViewController
{
extension
CollectionViewController
{
...
@@ -95,6 +100,14 @@ extension CollectionViewController {
...
@@ -95,6 +100,14 @@ extension CollectionViewController {
collectionView
.
delegate
=
self
collectionView
.
delegate
=
self
collectionView
.
dataSource
=
self
collectionView
.
dataSource
=
self
view
.
addSubview
(
collectionView
)
view
.
addSubview
(
collectionView
)
layoutCollectionView
()
}
}
extension
CollectionViewController
{
/// Sets the frame for the collectionView.
fileprivate
func
layoutCollectionView
()
{
collectionView
.
frame
=
view
.
bounds
}
}
}
}
...
...
Sources/iOS/NavigationController.swift
View file @
365cba14
...
@@ -108,8 +108,7 @@ open class NavigationController: UINavigationController {
...
@@ -108,8 +108,7 @@ open class NavigationController: UINavigationController {
open
override
func
viewWillLayoutSubviews
()
{
open
override
func
viewWillLayoutSubviews
()
{
super
.
viewWillLayoutSubviews
()
super
.
viewWillLayoutSubviews
()
navigationBar
.
setNeedsLayout
()
layoutSubviews
()
navigationBar
.
layoutIfNeeded
()
}
}
/**
/**
...
@@ -133,6 +132,12 @@ open class NavigationController: UINavigationController {
...
@@ -133,6 +132,12 @@ open class NavigationController: UINavigationController {
v
.
delegate
=
self
v
.
delegate
=
self
}
}
}
}
/// Calls the layout functions for the view heirarchy.
open
func
layoutSubviews
()
{
navigationBar
.
setNeedsLayout
()
navigationBar
.
layoutIfNeeded
()
}
}
}
extension
NavigationController
:
UINavigationBarDelegate
{
extension
NavigationController
:
UINavigationBarDelegate
{
...
...
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