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
84eeb69a
Commit
84eeb69a
authored
Oct 11, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added UIFont extension for calculating CGSize of text
parent
e4c4ea9a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
13 deletions
+44
-13
MaterialKit.xcodeproj/project.pbxproj
+12
-0
Source/Material+UIFont.swift
+31
-0
Source/MaterialTextLayer.swift
+1
-13
No files found.
MaterialKit.xcodeproj/project.pbxproj
View file @
84eeb69a
...
@@ -65,6 +65,7 @@
...
@@ -65,6 +65,7 @@
965C17CA1BC82FEF00B1059A
/* ImageCardView.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96D26BFC1BC23649006478BD
/* ImageCardView.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
965C17CA1BC82FEF00B1059A
/* ImageCardView.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96D26BFC1BC23649006478BD
/* ImageCardView.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
965C17CB1BC82FEF00B1059A
/* MaterialCollectionViewCell.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965C17C41BC8273D00B1059A
/* MaterialCollectionViewCell.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
965C17CB1BC82FEF00B1059A
/* MaterialCollectionViewCell.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965C17C41BC8273D00B1059A
/* MaterialCollectionViewCell.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
965C17CC1BC82FEF00B1059A
/* BasicCollectionViewCell.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965C17C61BC8279F00B1059A
/* BasicCollectionViewCell.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
965C17CC1BC82FEF00B1059A
/* BasicCollectionViewCell.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
965C17C61BC8279F00B1059A
/* BasicCollectionViewCell.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
9693BF861BCB0E0A0087054A
/* Material+UIFont.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9693BF851BCB0E0A0087054A
/* Material+UIFont.swift */
;
settings
=
{
ASSET_TAGS
=
();
};
};
9699879C1BC5FE49006D678E
/* MaterialTextLayer.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9699879B1BC5FE49006D678E
/* MaterialTextLayer.swift */
;
settings
=
{
ASSET_TAGS
=
();
};
};
9699879C1BC5FE49006D678E
/* MaterialTextLayer.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9699879B1BC5FE49006D678E
/* MaterialTextLayer.swift */
;
settings
=
{
ASSET_TAGS
=
();
};
};
96C4FABE1BC3168900E4FFC3
/* MaterialTransitionAnimation.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96C4FABD1BC3168900E4FFC3
/* MaterialTransitionAnimation.swift */
;
settings
=
{
ASSET_TAGS
=
();
};
};
96C4FABE1BC3168900E4FFC3
/* MaterialTransitionAnimation.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96C4FABD1BC3168900E4FFC3
/* MaterialTransitionAnimation.swift */
;
settings
=
{
ASSET_TAGS
=
();
};
};
96D26BFD1BC23649006478BD
/* ImageCardView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96D26BFC1BC23649006478BD
/* ImageCardView.swift */
;
settings
=
{
ASSET_TAGS
=
();
};
};
96D26BFD1BC23649006478BD
/* ImageCardView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96D26BFC1BC23649006478BD
/* ImageCardView.swift */
;
settings
=
{
ASSET_TAGS
=
();
};
};
...
@@ -120,6 +121,7 @@
...
@@ -120,6 +121,7 @@
964B17D81BBB3911002A9CA0
/* BasicCardView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
BasicCardView.swift
;
sourceTree
=
"<group>"
;
};
964B17D81BBB3911002A9CA0
/* BasicCardView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
BasicCardView.swift
;
sourceTree
=
"<group>"
;
};
965C17C41BC8273D00B1059A
/* MaterialCollectionViewCell.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialCollectionViewCell.swift
;
sourceTree
=
"<group>"
;
};
965C17C41BC8273D00B1059A
/* MaterialCollectionViewCell.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialCollectionViewCell.swift
;
sourceTree
=
"<group>"
;
};
965C17C61BC8279F00B1059A
/* BasicCollectionViewCell.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
BasicCollectionViewCell.swift
;
sourceTree
=
"<group>"
;
};
965C17C61BC8279F00B1059A
/* BasicCollectionViewCell.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
BasicCollectionViewCell.swift
;
sourceTree
=
"<group>"
;
};
9693BF851BCB0E0A0087054A
/* Material+UIFont.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+UIFont.swift"
;
sourceTree
=
"<group>"
;
};
9699879B1BC5FE49006D678E
/* MaterialTextLayer.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialTextLayer.swift
;
sourceTree
=
"<group>"
;
};
9699879B1BC5FE49006D678E
/* MaterialTextLayer.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialTextLayer.swift
;
sourceTree
=
"<group>"
;
};
96C4FABD1BC3168900E4FFC3
/* MaterialTransitionAnimation.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialTransitionAnimation.swift
;
sourceTree
=
"<group>"
;
};
96C4FABD1BC3168900E4FFC3
/* MaterialTransitionAnimation.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialTransitionAnimation.swift
;
sourceTree
=
"<group>"
;
};
96D26BFC1BC23649006478BD
/* ImageCardView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ImageCardView.swift
;
sourceTree
=
"<group>"
;
};
96D26BFC1BC23649006478BD
/* ImageCardView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ImageCardView.swift
;
sourceTree
=
"<group>"
;
};
...
@@ -230,6 +232,7 @@
...
@@ -230,6 +232,7 @@
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
963832631B88E5BF0015F710
/* LICENSE */
,
963832631B88E5BF0015F710
/* LICENSE */
,
9693BF841BCB0DEE0087054A
/* Extensions */
,
9638325C1B88E3420015F710
/* Supporting Files */
,
9638325C1B88E3420015F710
/* Supporting Files */
,
96B57D4C1B90AF6A00DE7BBB
/* Theme */
,
96B57D4C1B90AF6A00DE7BBB
/* Theme */
,
9AAC38521B89553800FE6B2D
/* Font */
,
9AAC38521B89553800FE6B2D
/* Font */
,
...
@@ -305,6 +308,14 @@
...
@@ -305,6 +308,14 @@
name
=
Collection
;
name
=
Collection
;
sourceTree
=
"<group>"
;
sourceTree
=
"<group>"
;
};
};
9693BF841BCB0DEE0087054A
/* Extensions */
=
{
isa
=
PBXGroup
;
children
=
(
9693BF851BCB0E0A0087054A
/* Material+UIFont.swift */
,
);
name
=
Extensions
;
sourceTree
=
"<group>"
;
};
96B57D4C1B90AF6A00DE7BBB
/* Theme */
=
{
96B57D4C1B90AF6A00DE7BBB
/* Theme */
=
{
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
...
@@ -497,6 +508,7 @@
...
@@ -497,6 +508,7 @@
65BDD1721BB8CD77006F7F2B
/* MaterialLabel.swift in Sources */
,
65BDD1721BB8CD77006F7F2B
/* MaterialLabel.swift in Sources */
,
65BDD1491BB5DC98006F7F2B
/* MaterialColor.swift in Sources */
,
65BDD1491BB5DC98006F7F2B
/* MaterialColor.swift in Sources */
,
965C17C71BC8279F00B1059A
/* BasicCollectionViewCell.swift in Sources */
,
965C17C71BC8279F00B1059A
/* BasicCollectionViewCell.swift in Sources */
,
9693BF861BCB0E0A0087054A
/* Material+UIFont.swift in Sources */
,
96C4FABE1BC3168900E4FFC3
/* MaterialTransitionAnimation.swift in Sources */
,
96C4FABE1BC3168900E4FFC3
/* MaterialTransitionAnimation.swift in Sources */
,
65D2BEC91BBED1FA00800B7B
/* MaterialKeyframeAnimation.swift in Sources */
,
65D2BEC91BBED1FA00800B7B
/* MaterialKeyframeAnimation.swift in Sources */
,
65D2BEC71BBED1E400800B7B
/* MaterialBasicAnimation.swift in Sources */
,
65D2BEC71BBED1E400800B7B
/* MaterialBasicAnimation.swift in Sources */
,
...
...
Source/Material+UIFont.swift
0 → 100644
View file @
84eeb69a
//
// Copyright (C) 2015 GraphKit, Inc. <http://graphkit.io> and other GraphKit contributors.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program located at the root of the software package
// in a file called LICENSE. If not, see <http://www.gnu.org/licenses/>.
//
import
UIKit
public
extension
UIFont
{
/**
:name: stringSize
*/
public
func
stringSize
(
string
:
String
,
constrainedToWidth
width
:
Double
)
->
CGSize
{
return
string
.
boundingRectWithSize
(
CGSize
(
width
:
width
,
height
:
DBL_MAX
),
options
:
NSStringDrawingOptions
.
UsesLineFragmentOrigin
,
attributes
:
[
NSFontAttributeName
:
self
],
context
:
nil
)
.
size
}
}
Source/MaterialTextLayer.swift
View file @
84eeb69a
...
@@ -18,18 +18,6 @@
...
@@ -18,18 +18,6 @@
import
UIKit
import
UIKit
public
extension
UIFont
{
/**
: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
],
context
:
nil
)
.
size
}
}
public
class
MaterialTextLayer
:
CATextLayer
{
public
class
MaterialTextLayer
:
CATextLayer
{
//
//
// :name: internalFont
// :name: internalFont
...
@@ -150,7 +138,7 @@ public class MaterialTextLayer : CATextLayer {
...
@@ -150,7 +138,7 @@ public class MaterialTextLayer : CATextLayer {
public
func
stringSize
(
constrainedToWidth
width
:
Double
)
->
CGSize
{
public
func
stringSize
(
constrainedToWidth
width
:
Double
)
->
CGSize
{
if
let
v
:
UIFont
=
internalFont
{
if
let
v
:
UIFont
=
internalFont
{
if
0
<
text
?
.
utf16
.
count
{
if
0
<
text
?
.
utf16
.
count
{
return
v
.
s
izeOfString
(
text
!
,
constrainedToWidth
:
width
)
return
v
.
s
tringSize
(
text
!
,
constrainedToWidth
:
width
)
}
}
}
}
return
CGSizeZero
return
CGSizeZero
...
...
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