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
7e12ec6e
Commit
7e12ec6e
authored
Sep 29, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
experimental: added textAlignment to MaterialLabel
parent
1986b113
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
11 deletions
+49
-11
Source/MaterialLabel.swift
+20
-0
Source/NavigationBarView.swift
+29
-11
No files found.
Source/MaterialLabel.swift
View file @
7e12ec6e
...
...
@@ -64,6 +64,26 @@ public class MaterialLabel : UILabel {
}
/**
:name: textAlignment
*/
public
override
var
textAlignment
:
NSTextAlignment
{
didSet
{
switch
textAlignment
{
case
.
Left
:
textLayer
.
alignmentMode
=
kCAAlignmentLeft
case
.
Center
:
textLayer
.
alignmentMode
=
kCAAlignmentCenter
case
.
Right
:
textLayer
.
alignmentMode
=
kCAAlignmentRight
case
.
Justified
:
textLayer
.
alignmentMode
=
kCAAlignmentJustified
case
.
Natural
:
textLayer
.
alignmentMode
=
kCAAlignmentNatural
}
}
}
/**
:name: init
*/
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
...
...
Source/NavigationBarView.swift
View file @
7e12ec6e
...
...
@@ -19,6 +19,11 @@
import
UIKit
public
class
NavigationBarView
:
MaterialView
{
//
// :name: isLoading
//
internal
lazy
var
isLoading
:
Bool
=
false
/**
:name: statusBarStyle
*/
...
...
@@ -40,17 +45,22 @@ public class NavigationBarView: MaterialView {
/**
:name: contentInsetsRef
*/
public
var
contentInsetsRef
:
MaterialInsetsType
!
public
var
contentInsetsRef
:
MaterialInsetsType
!
{
didSet
{
reloadView
()
}
}
/**
:name: titleLabel
*/
public
var
titleLabel
:
Material
Label
?
{
public
var
titleLabel
:
UI
Label
?
{
didSet
{
if
let
v
=
titleLabel
{
v
.
translatesAutoresizingMaskIntoConstraints
=
false
addSubview
(
v
)
}
reloadView
()
}
}
...
...
@@ -78,28 +88,36 @@ public class NavigationBarView: MaterialView {
/**
:name: init
*/
public
convenience
init
?(
titleLabel
:
Material
Label
?
=
nil
)
{
public
convenience
init
?(
titleLabel
:
UI
Label
?
=
nil
)
{
self
.
init
(
frame
:
CGRectMake
(
MaterialTheme
.
navigation
.
x
,
MaterialTheme
.
navigation
.
y
,
MaterialTheme
.
navigation
.
width
,
MaterialTheme
.
navigation
.
height
))
self
.
prepareProperties
(
titleLabel
)
}
/**
:name:
layoutSubviews
:name:
reloadView
*/
public
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
if
nil
!=
contentInsetsRef
{
public
func
reloadView
()
{
if
false
==
isLoading
&&
nil
!=
contentInsetsRef
{
isLoading
=
true
// clear constraints so new ones do not conflict
removeConstraints
(
constraints
)
MaterialLayout
.
alignToParentHorizontallyWithPad
(
self
,
child
:
titleLabel
!
,
left
:
contentInsetsRef
!.
left
,
right
:
contentInsetsRef
!.
right
)
MaterialLayout
.
alignFromBottom
(
self
,
child
:
titleLabel
!
,
bottom
:
contentInsetsRef
!.
bottom
)
if
nil
!=
titleLabel
{
MaterialLayout
.
alignToParentHorizontallyWithPad
(
self
,
child
:
titleLabel
!
,
left
:
contentInsetsRef
!.
left
,
right
:
contentInsetsRef
!.
right
)
MaterialLayout
.
alignFromBottom
(
self
,
child
:
titleLabel
!
,
bottom
:
contentInsetsRef
!.
bottom
)
}
isLoading
=
false
}
}
//
// :name: prepareProperties
//
internal
func
prepareProperties
(
titleLabel
:
Material
Label
?)
{
internal
func
prepareProperties
(
titleLabel
:
UI
Label
?)
{
self
.
titleLabel
=
titleLabel
}
...
...
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