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
55d463fa
Commit
55d463fa
authored
Sep 29, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
experimental: added truncation to MaterialLabel and updated defaults for NavigationBarView
parent
270558a5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
3 deletions
+46
-3
Source/MaterialLabel.swift
+40
-1
Source/MaterialTheme.swift
+5
-2
Source/NavigationBarView.swift
+1
-0
No files found.
Source/MaterialLabel.swift
View file @
55d463fa
...
@@ -58,12 +58,21 @@ public class MaterialLabel : UILabel {
...
@@ -58,12 +58,21 @@ public class MaterialLabel : UILabel {
didSet
{
didSet
{
if
let
v
=
font
{
if
let
v
=
font
{
textLayer
.
font
=
CGFontCreateWithFontName
(
v
.
fontName
as
CFStringRef
)
!
textLayer
.
font
=
CGFontCreateWithFontName
(
v
.
fontName
as
CFStringRef
)
!
textLayer
.
fo
ntSize
=
v
.
pointSize
poi
ntSize
=
v
.
pointSize
}
}
}
}
}
}
/**
/**
:name: pointSize
*/
public
var
pointSize
:
CGFloat
!
{
didSet
{
textLayer
.
fontSize
=
pointSize
}
}
/**
:name: textAlignment
:name: textAlignment
*/
*/
public
override
var
textAlignment
:
NSTextAlignment
{
public
override
var
textAlignment
:
NSTextAlignment
{
...
@@ -102,6 +111,34 @@ public class MaterialLabel : UILabel {
...
@@ -102,6 +111,34 @@ public class MaterialLabel : UILabel {
}
}
/**
/**
:name: lineBreakMode
*/
public
override
var
lineBreakMode
:
NSLineBreakMode
{
didSet
{
switch
lineBreakMode
{
case
.
ByWordWrapping
:
// Wrap at word boundaries, default
wrapped
=
true
textLayer
.
truncationMode
=
kCATruncationNone
case
.
ByCharWrapping
:
// Wrap at character boundaries
wrapped
=
true
textLayer
.
truncationMode
=
kCATruncationNone
case
.
ByClipping
:
// Simply clip
wrapped
=
false
textLayer
.
truncationMode
=
kCATruncationNone
case
.
ByTruncatingHead
:
// Truncate at head of line: "...wxyz"
wrapped
=
false
textLayer
.
truncationMode
=
kCATruncationStart
case
.
ByTruncatingTail
:
// Truncate at tail of line: "abcd..."
wrapped
=
false
textLayer
.
truncationMode
=
kCATruncationEnd
case
.
ByTruncatingMiddle
:
// Truncate middle of line: "ab...yz"
wrapped
=
false
textLayer
.
truncationMode
=
kCATruncationMiddle
}
}
}
/**
:name: init
:name: init
*/
*/
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
...
@@ -130,5 +167,6 @@ public class MaterialLabel : UILabel {
...
@@ -130,5 +167,6 @@ public class MaterialLabel : UILabel {
textAlignment
=
MaterialTheme
.
label
.
textAlignment
textAlignment
=
MaterialTheme
.
label
.
textAlignment
wrapped
=
MaterialTheme
.
label
.
wrapped
wrapped
=
MaterialTheme
.
label
.
wrapped
contentsScale
=
MaterialTheme
.
label
.
contentsScale
contentsScale
=
MaterialTheme
.
label
.
contentsScale
font
=
MaterialTheme
.
label
.
font
}
}
}
}
\ No newline at end of file
Source/MaterialTheme.swift
View file @
55d463fa
...
@@ -119,7 +119,7 @@ public extension MaterialTheme.navigation {
...
@@ -119,7 +119,7 @@ public extension MaterialTheme.navigation {
// shape
// shape
public
static
var
masksToBounds
:
Bool
=
MaterialTheme
.
view
.
masksToBounds
public
static
var
masksToBounds
:
Bool
=
MaterialTheme
.
view
.
masksToBounds
public
static
var
cornerRadius
:
MaterialRadius
=
MaterialTheme
.
view
.
cornerRadius
public
static
var
cornerRadius
:
MaterialRadius
=
MaterialTheme
.
view
.
cornerRadius
public
static
var
titleInsetsRef
:
MaterialInsetsType
=
(
top
:
0
,
left
:
8
,
bottom
:
1
2
,
right
:
8
)
public
static
var
titleInsetsRef
:
MaterialInsetsType
=
(
top
:
0
,
left
:
8
,
bottom
:
1
0
,
right
:
8
)
public
static
var
leftButtonsInsetsRef
:
MaterialInsetsType
=
(
top
:
0
,
left
:
8
,
bottom
:
8
,
right
:
0
)
public
static
var
leftButtonsInsetsRef
:
MaterialInsetsType
=
(
top
:
0
,
left
:
8
,
bottom
:
8
,
right
:
0
)
public
static
var
rightButtonsInsetsRef
:
MaterialInsetsType
=
(
top
:
0
,
left
:
0
,
bottom
:
8
,
right
:
8
)
public
static
var
rightButtonsInsetsRef
:
MaterialInsetsType
=
(
top
:
0
,
left
:
0
,
bottom
:
8
,
right
:
8
)
...
@@ -149,9 +149,12 @@ public extension MaterialTheme.label {
...
@@ -149,9 +149,12 @@ public extension MaterialTheme.label {
// scale
// scale
public
static
var
contentsScale
:
CGFloat
=
UIScreen
.
mainScreen
()
.
scale
public
static
var
contentsScale
:
CGFloat
=
UIScreen
.
mainScreen
()
.
scale
//
tex
t
//
alignmen
t
public
static
var
wrapped
:
Bool
=
true
public
static
var
wrapped
:
Bool
=
true
public
static
var
textAlignment
:
NSTextAlignment
=
.
Left
public
static
var
textAlignment
:
NSTextAlignment
=
.
Left
// font
public
static
var
font
:
UIFont
=
RobotoFont
.
regularWithSize
(
20
)
}
}
// button.flat
// button.flat
...
...
Source/NavigationBarView.swift
View file @
55d463fa
...
@@ -164,6 +164,7 @@ public class NavigationBarView: MaterialView {
...
@@ -164,6 +164,7 @@ public class NavigationBarView: MaterialView {
v
.
removeFromSuperview
()
v
.
removeFromSuperview
()
}
}
// leftButtons
if
let
v
=
leftButtons
{
if
let
v
=
leftButtons
{
var
h
:
String
=
"H:|"
var
h
:
String
=
"H:|"
var
d
:
Dictionary
<
String
,
AnyObject
>
=
Dictionary
<
String
,
AnyObject
>
()
var
d
:
Dictionary
<
String
,
AnyObject
>
=
Dictionary
<
String
,
AnyObject
>
()
...
...
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