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
f8d2977c
Commit
f8d2977c
authored
Dec 05, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated README with CardView example 2
parent
36c254b6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
5 deletions
+52
-5
Examples/CardView/CardView/ViewController.swift
+46
-1
README.md
+2
-0
Sources/MaterialGravity.swift
+4
-4
No files found.
Examples/CardView/CardView/ViewController.swift
View file @
f8d2977c
...
...
@@ -28,7 +28,8 @@ class ViewController: UIViewController {
// Uncomment different examples and read
// the comments below.
// prepareGeneralCardView()
prepareCardViewWithoutDivider
()
// prepareCardViewWithoutDivider()
prepareCardViewWithBackgroundImage
()
}
/**
...
...
@@ -127,5 +128,49 @@ class ViewController: UIViewController {
MaterialLayout
.
alignFromTop
(
view
,
child
:
cardView
,
top
:
100
)
MaterialLayout
.
alignToParentHorizontally
(
view
,
child
:
cardView
,
left
:
20
,
right
:
20
)
}
/**
:name: prepareCardViewWithBackgroundImage
:description: An example of the CardView with a background image.
*/
private
func
prepareCardViewWithBackgroundImage
()
{
let
cardView
:
CardView
=
CardView
()
cardView
.
dividerInsetsRef
.
left
=
100
cardView
.
titleLabelInsetsRef
.
left
=
100
cardView
.
detailLabelInsetsRef
.
left
=
100
// Image.
cardView
.
image
=
UIImage
(
named
:
"MaterialKitCardViewBackgroundImage"
)?
.
resize
(
toWidth
:
300
)
cardView
.
contentsGravity
=
.
TopLeft
// Title label.
let
titleLabel
:
UILabel
=
UILabel
()
titleLabel
.
text
=
"Focus"
titleLabel
.
font
=
RobotoFont
.
mediumWithSize
(
24
)
cardView
.
titleLabel
=
titleLabel
// Detail label
let
detailLabel
:
UILabel
=
UILabel
()
detailLabel
.
text
=
"Easily organize your thoughts using hashtags."
detailLabel
.
numberOfLines
=
0
cardView
.
detailLabel
=
detailLabel
// ITUNES button.
let
btn1
:
FlatButton
=
FlatButton
()
btn1
.
pulseColor
=
MaterialColor
.
blue
.
lighten1
btn1
.
pulseFill
=
true
btn1
.
pulseScale
=
false
btn1
.
setTitle
(
"ITUNES"
,
forState
:
.
Normal
)
btn1
.
setTitleColor
(
MaterialColor
.
blue
.
darken1
,
forState
:
.
Normal
)
// Add buttons to right side.
cardView
.
rightButtons
=
[
btn1
]
// To support orientation changes, use MaterialLayout.
view
.
addSubview
(
cardView
)
cardView
.
translatesAutoresizingMaskIntoConstraints
=
false
MaterialLayout
.
alignFromTop
(
view
,
child
:
cardView
,
top
:
100
)
MaterialLayout
.
alignToParentHorizontally
(
view
,
child
:
cardView
,
left
:
20
,
right
:
20
)
}
}
README.md
View file @
f8d2977c
...
...
@@ -26,6 +26,8 @@ Right out of the box to a fully customized configuration, CardView always stands


### License
[
AGPL-3.0
](
http://choosealicense.com/licenses/agpl-3.0/
)
Sources/MaterialGravity.swift
View file @
f8d2977c
...
...
@@ -51,13 +51,13 @@ public func MaterialGravityToString(gravity: MaterialGravity) -> String {
case
.
Right
:
return
kCAGravityRight
case
.
TopLeft
:
return
kCAGravity
Top
Left
return
kCAGravity
Bottom
Left
case
.
TopRight
:
return
kCAGravity
Top
Right
return
kCAGravity
Bottom
Right
case
.
BottomLeft
:
return
kCAGravity
Bottom
Left
return
kCAGravity
Top
Left
case
.
BottomRight
:
return
kCAGravity
Bottom
Right
return
kCAGravity
Top
Right
case
.
Resize
:
return
kCAGravityResize
case
.
ResizeAspect
:
...
...
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