Skip to content

Commit c4fbcaa

Browse files
committed
Merge branch 'release/2.0.4'
2 parents b9e2080 + 8658ce3 commit c4fbcaa

File tree

8 files changed

+83
-40
lines changed

8 files changed

+83
-40
lines changed

ExampleiOS/Base.lproj/Main.storyboard

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.13.2" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
33
<device id="retina4_7" orientation="portrait">
44
<adaptation id="fullscreen"/>
55
</device>
66
<dependencies>
77
<deployment identifier="iOS"/>
8-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.9"/>
99
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
1010
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
1111
</dependencies>
@@ -22,26 +22,25 @@
2222
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
2323
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
2424
<subviews>
25-
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Hello &lt;bold&gt;Daniele!&lt;/bold&gt;. You're ready to &lt;red&gt;play with us!&lt;/red&gt;" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="O4i-ta-tn6">
26-
<rect key="frame" x="15" y="35" width="345" height="41"/>
27-
<fontDescription key="fontDescription" type="system" pointSize="17"/>
28-
<nil key="textColor"/>
29-
<nil key="highlightedColor"/>
30-
<userDefinedRuntimeAttributes>
31-
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="MyStyle"/>
32-
</userDefinedRuntimeAttributes>
33-
</label>
25+
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="M2v-v6-dEE">
26+
<rect key="frame" x="10" y="30" width="355" height="627"/>
27+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
28+
<string key="text">Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.</string>
29+
<fontDescription key="fontDescription" type="system" pointSize="14"/>
30+
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
31+
</textView>
3432
</subviews>
3533
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
3634
<constraints>
37-
<constraint firstAttribute="trailing" secondItem="O4i-ta-tn6" secondAttribute="trailing" constant="15" id="n1t-VD-qAb"/>
38-
<constraint firstItem="O4i-ta-tn6" firstAttribute="top" secondItem="W24-AA-bsh" secondAttribute="bottom" constant="15" id="qh4-kV-ULG"/>
39-
<constraint firstItem="O4i-ta-tn6" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" constant="15" id="rLN-3M-CG5"/>
35+
<constraint firstItem="M2v-v6-dEE" firstAttribute="top" secondItem="W24-AA-bsh" secondAttribute="bottom" constant="10" id="2dY-QZ-gnJ"/>
36+
<constraint firstItem="M2v-v6-dEE" firstAttribute="leading" secondItem="KdN-DI-2Ar" secondAttribute="leading" constant="10" id="WyS-va-4aK"/>
37+
<constraint firstItem="rLU-7s-8uZ" firstAttribute="top" secondItem="M2v-v6-dEE" secondAttribute="bottom" constant="10" id="iOv-kK-yJx"/>
38+
<constraint firstItem="KdN-DI-2Ar" firstAttribute="trailing" secondItem="M2v-v6-dEE" secondAttribute="trailing" constant="10" id="tlk-Hm-QJ8"/>
4039
</constraints>
4140
<viewLayoutGuide key="safeArea" id="KdN-DI-2Ar"/>
4241
</view>
4342
<connections>
44-
<outlet property="label" destination="O4i-ta-tn6" id="DUC-Oc-2VZ"/>
43+
<outlet property="textView" destination="M2v-v6-dEE" id="9WS-vx-fka"/>
4544
</connections>
4645
</viewController>
4746
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>

ExampleiOS/ViewController.swift

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,50 @@ import UIKit
1010

1111
class ViewController: UIViewController {
1212

13-
@IBOutlet public var label: UILabel?
13+
@IBOutlet public var textView: UITextView?
14+
15+
let baseFontSize: CGFloat = 16
1416

1517
override func viewDidLoad() {
1618
super.viewDidLoad()
19+
20+
let bodyHTML = try! String(contentsOfFile: Bundle.main.path(forResource: "file", ofType: "txt")!)
21+
22+
let headerStyle = Style {
23+
$0.font = UIFont.boldSystemFont(ofSize: self.baseFontSize * 1.15)
24+
$0.lineSpacing = 1
25+
$0.kerning = Kerning.adobe(-20)
26+
}
27+
let boldStyle = Style {
28+
$0.font = UIFont.boldSystemFont(ofSize: self.baseFontSize)
29+
}
30+
let italicStyle = Style {
31+
$0.font = UIFont.italicSystemFont(ofSize: self.baseFontSize)
32+
}
33+
34+
let style = StyleGroup(base: Style {
35+
$0.font = UIFont.systemFont(ofSize: self.baseFontSize)
36+
$0.lineSpacing = 2
37+
$0.kerning = Kerning.adobe(-15)
38+
}, [
39+
"h3": headerStyle,
40+
"h4": headerStyle,
41+
"h5": headerStyle,
42+
"strong": boldStyle,
43+
"b": boldStyle,
44+
"em": italicStyle,
45+
"i": italicStyle,
46+
"li": Style {
47+
$0.paragraphSpacingBefore = self.baseFontSize / 2
48+
$0.firstLineHeadIndent = self.baseFontSize
49+
$0.headIndent = self.baseFontSize * 1.71
50+
},
51+
"sup": Style {
52+
$0.font = UIFont.systemFont(ofSize: self.baseFontSize / 1.2)
53+
$0.baselineOffset = Float(self.baseFontSize) / 3.5
54+
}])
55+
56+
self.textView?.attributedText = bodyHTML.set(style: style)
1757
}
1858

1959
override func didReceiveMemoryWarning() {

ExampleiOS/file.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<strong>Parler du don d'organe n'est plus tabou. Je me renseigne, j'en discute avec mes proches,... et je décide!</strong>
2+
3+
En Belgique, au début des années 2000, le nombre de donneurs d’organes avait tendance à diminuer et les listes d’attente à augmenter considérablement ayant comme corollaire une augmentation de la mortalité des patients inscrits sur les listes d’attente.
4+
5+
Soucieux de cette situation, en juin 2005, le Ministre en charge de la Santé publique a souhaité mettre sur pied une vaste campagne de sensibilisation entièrement dédiée au don d’organes.
6+
7+
Depuis, de nombreuses actions entreprises par le SPF Santé publique viennent renforcer toutes celles qui sont accomplies au quotidien par les coordinateurs de transplantation, les coordinateurs locaux de don, les associations de familles de donneurs, les associations de patients transplantés et ce, depuis de très nombreuses années.
8+
9+
<strong>Objectifs poursuivis</strong>
10+
11+
Les objectifs principaux de cette campagne sont:
12+
<li style="text-align: justify;">• d’améliorer la sensibilisation au don auprès des différents groupes auxquels les messages s’adressent,</li>
13+
<li style="text-align: justify;">• d’inviter les citoyens à «oser» en parler en famille, entre amis, entre collègues. Aborder la mort – sa propre mort – reste relativement tabou pour beaucoup.</li>
14+
15+
<strong>Pour en savoir plus... <a href="http://www.health.belgium.be/fr/sante/prenez-soin-de-vous/debut-et-fin-de-vie/don-dorganes" target="_blank">www.health.belgium.be/fr/sante/prenez-soin-de-vous/debut-et-fin-de-vie/don-dorganes</a></strong>

Sources/SwiftRichString/Style/StyleGroup.swift

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,7 @@ public class StyleGroup: StyleProtocol {
180180
let str = attrStr.string
181181

182182
// Apply default base style if specified
183-
if let baseStyle = self.baseStyle {
184-
if adding {
185-
attrStr.addAttributes(baseStyle.attributes, range: NSMakeRange(0, attrStr.length))
186-
} else {
187-
attrStr.setAttributes(baseStyle.attributes, range: NSMakeRange(0, attrStr.length))
188-
}
189-
}
183+
self.baseStyle?.set(to: attrStr, range: nil)
190184

191185
// Parse tags
192186
if let regex = try? NSRegularExpression(pattern: tagRegex, options: .dotMatchesLineSeparators) {

Sources/SwiftRichString/Style/StyleProtocol.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,13 @@ public protocol StyleProtocol: class {
4141
var fontData: FontData? { get }
4242

4343
func set(to source: String, range: NSRange?) -> AttributedString
44+
4445
func add(to source: AttributedString, range: NSRange?) -> AttributedString
46+
47+
@discardableResult
4548
func set(to source: AttributedString, range: NSRange?) -> AttributedString
49+
50+
@discardableResult
4651
func remove(from source: AttributedString, range: NSRange?) -> AttributedString
4752
}
4853

@@ -61,12 +66,14 @@ public extension StyleProtocol {
6166
return source
6267
}
6368

69+
@discardableResult
6470
func set(to source: AttributedString, range: NSRange?) -> AttributedString {
6571
self.fontData?.addAttributes(to: source, range: range)
6672
source.addAttributes(self.attributes, range: (range ?? NSMakeRange(0, source.length)))
6773
return source
6874
}
6975

76+
@discardableResult
7077
func remove(from source: AttributedString, range: NSRange?) -> AttributedString {
7178
self.attributes.keys.forEach({
7279
source.removeAttribute($0, range: (range ?? NSMakeRange(0, source.length)))

SwiftRichString.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "SwiftRichString"
3-
s.version = "2.0.3"
3+
s.version = "2.0.4"
44
s.summary = "Elegant Strings & Attributed Strings Toolkit for Swift"
55
s.description = <<-DESC
66
SwiftRichString is the best toolkit to work easily with Strings and Attributed Strings.

SwiftRichString.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
64507F3320B1912B009455BD /* AssociatedValues.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507E7020AEF12C009455BD /* AssociatedValues.swift */; };
123123
64507F3420B1912B009455BD /* OrderedDictionary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507E7720AEF611009455BD /* OrderedDictionary.swift */; };
124124
64507F3520B1912B009455BD /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507EBD20B18489009455BD /* Extensions.swift */; };
125+
64774AD3213E91B9008F8DC3 /* file.txt in Resources */ = {isa = PBXBuildFile; fileRef = 64774AD2213E91B9008F8DC3 /* file.txt */; };
125126
648932CA209DE194000E691A /* CommonsAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 648932C9209DE194000E691A /* CommonsAttributes.swift */; };
126127
648932CB209DE194000E691A /* CommonsAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 648932C9209DE194000E691A /* CommonsAttributes.swift */; };
127128
648932CC209DE194000E691A /* CommonsAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 648932C9209DE194000E691A /* CommonsAttributes.swift */; };
@@ -277,6 +278,7 @@
277278
64507F1520B1911B009455BD /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
278279
64507F1720B1911B009455BD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
279280
64507F1820B1911B009455BD /* PushNotificationPayload.apns */ = {isa = PBXFileReference; lastKnownFileType = text; path = PushNotificationPayload.apns; sourceTree = "<group>"; };
281+
64774AD2213E91B9008F8DC3 /* file.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = file.txt; sourceTree = "<group>"; };
280282
648932C9209DE194000E691A /* CommonsAttributes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommonsAttributes.swift; sourceTree = "<group>"; };
281283
648932D3209DE44E000E691A /* FontConvertible.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FontConvertible.swift; sourceTree = "<group>"; };
282284
648932DC209DE474000E691A /* ExampleiOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ExampleiOS.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -538,6 +540,7 @@
538540
648932DE209DE474000E691A /* AppDelegate.swift */,
539541
648932E0209DE474000E691A /* ViewController.swift */,
540542
648932E2209DE474000E691A /* Main.storyboard */,
543+
64774AD2213E91B9008F8DC3 /* file.txt */,
541544
648932E5209DE476000E691A /* Assets.xcassets */,
542545
648932E7209DE476000E691A /* LaunchScreen.storyboard */,
543546
648932EA209DE476000E691A /* Info.plist */,
@@ -1000,6 +1003,7 @@
10001003
files = (
10011004
648932E9209DE476000E691A /* LaunchScreen.storyboard in Resources */,
10021005
648932E6209DE476000E691A /* Assets.xcassets in Resources */,
1006+
64774AD3213E91B9008F8DC3 /* file.txt in Resources */,
10031007
648932E4209DE474000E691A /* Main.storyboard in Resources */,
10041008
);
10051009
runOnlyForDeploymentPostprocessing = 0;

SwiftRichString.xcodeproj/xcuserdata/daniele.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,6 @@
1919
landmarkType = "24">
2020
</BreakpointContent>
2121
</BreakpointProxy>
22-
<BreakpointProxy
23-
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
24-
<BreakpointContent
25-
shouldBeEnabled = "Yes"
26-
ignoreCount = "0"
27-
continueAfterRunningActions = "No"
28-
filePath = "ExampleiOS/ViewController.swift"
29-
timestampString = "548505331.301084"
30-
startingColumnNumber = "9223372036854775807"
31-
endingColumnNumber = "9223372036854775807"
32-
startingLineNumber = "18"
33-
endingLineNumber = "18"
34-
landmarkName = "viewDidLoad()"
35-
landmarkType = "7">
36-
</BreakpointContent>
37-
</BreakpointProxy>
3822
<BreakpointProxy
3923
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
4024
<BreakpointContent

0 commit comments

Comments
 (0)