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
918b3f00
Unverified
Commit
918b3f00
authored
Nov 04, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
editor: added update attributes for CharacterAttributes
parent
59c008df
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
Sources/iOS/CharacterAttribute.swift
+44
-0
No files found.
Sources/iOS/CharacterAttribute.swift
View file @
918b3f00
...
...
@@ -133,6 +133,39 @@ extension NSMutableAttributedString {
}
/**
Adds a Dictionary of character attributes to a given range.
- Parameter characterAttributes: A Dictionary of CharacterAttribute type keys and Any type values.
- Parameter range: A NSRange.
*/
open
func
addAttributes
(
characterAttributes
:
[
CharacterAttribute
:
Any
]
=
[:],
range
:
NSRange
)
{
for
(
k
,
v
)
in
characterAttributes
{
addAttribute
(
characterAttribute
:
k
,
value
:
v
,
range
:
range
)
}
}
/**
Updates a character attribute to a given range.
- Parameter characterAttribute: A CharacterAttribute.
- Parameter value: Any type.
- Parameter range: A NSRange.
*/
open
func
updateAttribute
(
characterAttribute
:
CharacterAttribute
,
value
:
Any
,
range
:
NSRange
)
{
removeAttribute
(
characterAttribute
:
characterAttribute
,
range
:
range
)
addAttribute
(
characterAttribute
:
characterAttribute
,
value
:
value
,
range
:
range
)
}
/**
Updates a Dictionary of character attributes to a given range.
- Parameter characterAttributes: A Dictionary of CharacterAttribute type keys and Any type values.
- Parameter range: A NSRange.
*/
open
func
updateAttributes
(
characterAttributes
:
[
CharacterAttribute
:
Any
]
=
[:],
range
:
NSRange
)
{
for
(
k
,
v
)
in
characterAttributes
{
updateAttribute
(
characterAttribute
:
k
,
value
:
v
,
range
:
range
)
}
}
/**
Removes a character attribute from a given range.
- Parameter characterAttribute: A CharacterAttribute.
- Parameter range: A NSRange.
...
...
@@ -140,4 +173,15 @@ extension NSMutableAttributedString {
open
func
removeAttribute
(
characterAttribute
:
CharacterAttribute
,
range
:
NSRange
)
{
removeAttribute
(
CharacterAttributeToValue
(
attribute
:
characterAttribute
),
range
:
range
)
}
/**
Removes a Dictionary of character attributes from a given range.
- Parameter characterAttributes: An Array of CharacterAttributes.
- Parameter range: A NSRange.
*/
open
func
removeAttributes
(
characterAttributes
:
[
CharacterAttribute
]
=
[],
range
:
NSRange
)
{
for
k
in
characterAttributes
{
removeAttribute
(
characterAttribute
:
k
,
range
:
range
)
}
}
}
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