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
b5ac48a4
Commit
b5ac48a4
authored
Oct 08, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added defaults for MaterialTextLayer
parent
815e678f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
29 deletions
+44
-29
Source/MaterialLayer.swift
+0
-1
Source/MaterialTextLayer.swift
+25
-27
Source/MaterialTheme.swift
+19
-1
No files found.
Source/MaterialLayer.swift
View file @
b5ac48a4
...
...
@@ -19,7 +19,6 @@
import
UIKit
public
class
MaterialLayer
:
CAShapeLayer
{
/**
:name: init
*/
...
...
Source/MaterialTextLayer.swift
View file @
b5ac48a4
...
...
@@ -19,7 +19,10 @@
import
UIKit
public
extension
UIFont
{
func
sizeOfString
(
string
:
String
,
constrainedToWidth
width
:
Double
)
->
CGSize
{
/**
:name: sizeOfString
*/
public
func
sizeOfString
(
string
:
String
,
constrainedToWidth
width
:
Double
)
->
CGSize
{
return
string
.
boundingRectWithSize
(
CGSize
(
width
:
width
,
height
:
DBL_MAX
),
options
:
NSStringDrawingOptions
.
UsesLineFragmentOrigin
,
attributes
:
[
NSFontAttributeName
:
self
],
...
...
@@ -28,17 +31,14 @@ public extension UIFont {
}
public
class
MaterialTextLayer
:
CATextLayer
{
/**
:name: text
*/
public
var
text
:
String
?
{
didSet
{
string
=
text
as?
AnyObject
}
}
//
// :name: internalFont
//
private
var
internalFont
:
UIFont
?
/**
:name: font
*/
public
override
var
font
:
AnyObject
?
{
get
{
return
internalFont
...
...
@@ -53,25 +53,22 @@ public class MaterialTextLayer : CATextLayer {
}
/**
:name:
pointSize
:name:
text
*/
public
var
pointSize
:
CGFloat
=
10
{
public
var
text
:
String
?
{
didSet
{
fontSize
=
pointSize
string
=
text
as?
AnyObject
}
}
/**
:name:
font
:name:
pointSize
*/
// public override var font: AnyObject? {
//// didSet {
//// if let v = font as? UIFont {
//// super.font = CGFontCreateWithFontName(v.fontName as CFStringRef)!
//// pointSize = v.pointSize
//// }
//// }
// }
public
var
pointSize
:
CGFloat
=
10
{
didSet
{
fontSize
=
pointSize
}
}
/**
:name: textColor
...
...
@@ -169,11 +166,12 @@ public class MaterialTextLayer : CATextLayer {
// :name: prepareLayer
//
internal
func
prepareLayer
()
{
textColor
=
MaterialColor
.
black
textAlignment
=
MaterialTheme
.
label
.
textAlignment
wrapped
=
MaterialTheme
.
label
.
wrapped
contentsScale
=
MaterialTheme
.
label
.
contentsScale
font
=
MaterialTheme
.
label
.
font
textColor
=
MaterialTheme
.
textLayer
.
textColor
textAlignment
=
MaterialTheme
.
textLayer
.
textAlignment
wrapped
=
MaterialTheme
.
textLayer
.
wrapped
contentsScale
=
MaterialTheme
.
textLayer
.
contentsScale
font
=
MaterialTheme
.
textLayer
.
font
lineBreakMode
=
MaterialTheme
.
textLayer
.
lineBreakMode
}
}
Source/MaterialTheme.swift
View file @
b5ac48a4
...
...
@@ -24,6 +24,7 @@ public struct MaterialTheme {
public
struct
basicCardView
{}
public
struct
imageCardView
{}
public
struct
navigationBarView
{}
public
struct
textLayer
{}
public
struct
label
{}
public
struct
flatButton
{}
public
struct
raisedButton
{}
...
...
@@ -216,6 +217,23 @@ public extension MaterialTheme.navigationBarView {
public
static
var
zPosition
:
CGFloat
=
100
}
// textLayer
public
extension
MaterialTheme
.
textLayer
{
// scale
public
static
var
contentsScale
:
CGFloat
=
UIScreen
.
mainScreen
()
.
scale
// alignment
public
static
var
wrapped
:
Bool
=
true
public
static
var
textAlignment
:
NSTextAlignment
=
.
Left
public
static
var
lineBreakMode
:
NSLineBreakMode
=
.
ByWordWrapping
// font
public
static
var
font
:
UIFont
=
RobotoFont
.
regular
// color
public
static
var
textColor
:
UIColor
=
MaterialColor
.
black
}
// label
public
extension
MaterialTheme
.
label
{
// scale
...
...
@@ -226,7 +244,7 @@ public extension MaterialTheme.label {
public
static
var
textAlignment
:
NSTextAlignment
=
.
Left
// font
public
static
var
font
:
UIFont
=
RobotoFont
.
regular
WithSize
(
20
)
public
static
var
font
:
UIFont
=
RobotoFont
.
regular
}
// flatButton
...
...
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