Skip to content

Commit 50b7333

Browse files
committed
complete framework and demo
1 parent 7bd1d0b commit 50b7333

File tree

18 files changed

+895
-165
lines changed

18 files changed

+895
-165
lines changed

AttributedStringWrapper.podspec

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Pod::Spec.new do |s|
2+
3+
s.name = "AttributedStringWrapper"
4+
s.version = "1.0.0"
5+
s.summary = "A simple packaging for NSAttributedString to make the developers easy to use"
6+
7+
s.homepage = "https://github.com/loopeer/AttributedStringWrapper"
8+
s.license = { :type => "MIT", :file => "LICENSE" }
9+
10+
s.authors = { "gaoyu" => "gaoyu@loopeer.com" }
11+
s.social_media_url = "http://www.jianshu.com/u/c4a4505bef4f"
12+
s.source = { :git => "https://github.com/loopeer/AttributedStringWrapper.git", :tag => s.version }
13+
14+
s.source_files = ["Sources/*.swift", "Sources/AttributedStringWrapper.h"]
15+
s.public_header_files = ["Sources/AttributedStringWrapper.h"]
16+
17+
18+
s.ios.deployment_target = "8.0"
19+
s.requires_arc = true
20+
s.pod_target_xcconfig = { 'SWIFT_VERSION' => '3.0' }
21+
22+
end

AttributedStringWrapper.xcodeproj/project.pbxproj

Lines changed: 426 additions & 111 deletions
Large diffs are not rendered by default.

AttributedStringWrapper.xcworkspace/contents.xcworkspacedata

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AttributedStringWrapper/Base.lproj/Main.storyboard

Lines changed: 0 additions & 26 deletions
This file was deleted.

AttributedStringWrapper/ViewController.swift

Lines changed: 0 additions & 25 deletions
This file was deleted.

AttributedStringWrapper/AppDelegate.swift renamed to Demo/AppDelegate.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//
22
// AppDelegate.swift
3-
// AttributedStringWrapper
3+
// Demo
44
//
5-
// Created by 郜宇 on 2017/6/12.
5+
// Created by 郜宇 on 2017/6/13.
66
// Copyright © 2017年 Loopeer. All rights reserved.
77
//
88

Demo/Base.lproj/Main.storyboard

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12120" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3+
<device id="retina4_7" orientation="portrait">
4+
<adaptation id="fullscreen"/>
5+
</device>
6+
<dependencies>
7+
<deployment identifier="iOS"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
9+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
10+
</dependencies>
11+
<scenes>
12+
<!--View Controller-->
13+
<scene sceneID="tne-QT-ifu">
14+
<objects>
15+
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="Demo" customModuleProvider="target" sceneMemberID="viewController">
16+
<layoutGuides>
17+
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
18+
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
19+
</layoutGuides>
20+
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
21+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
22+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
23+
<subviews>
24+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2DU-C7-txT">
25+
<rect key="frame" x="10" y="45" width="355" height="17"/>
26+
<fontDescription key="fontDescription" type="system" pointSize="14"/>
27+
<nil key="textColor"/>
28+
<nil key="highlightedColor"/>
29+
</label>
30+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="D4r-z3-VgR">
31+
<rect key="frame" x="10" y="87" width="355" height="17"/>
32+
<fontDescription key="fontDescription" type="system" pointSize="14"/>
33+
<nil key="textColor"/>
34+
<nil key="highlightedColor"/>
35+
</label>
36+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="j3e-4r-Hrj">
37+
<rect key="frame" x="10" y="129" width="355" height="17"/>
38+
<fontDescription key="fontDescription" type="system" pointSize="14"/>
39+
<nil key="textColor"/>
40+
<nil key="highlightedColor"/>
41+
</label>
42+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YA0-fO-QN5">
43+
<rect key="frame" x="10" y="171" width="355" height="17"/>
44+
<fontDescription key="fontDescription" type="system" pointSize="14"/>
45+
<nil key="textColor"/>
46+
<nil key="highlightedColor"/>
47+
</label>
48+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="jVc-Ry-Mux">
49+
<rect key="frame" x="10" y="213" width="355" height="17"/>
50+
<fontDescription key="fontDescription" type="system" pointSize="14"/>
51+
<nil key="textColor"/>
52+
<nil key="highlightedColor"/>
53+
</label>
54+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="iwc-9i-mzD">
55+
<rect key="frame" x="10" y="255" width="355" height="17"/>
56+
<fontDescription key="fontDescription" type="system" pointSize="14"/>
57+
<nil key="textColor"/>
58+
<nil key="highlightedColor"/>
59+
</label>
60+
</subviews>
61+
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
62+
<constraints>
63+
<constraint firstItem="D4r-z3-VgR" firstAttribute="top" secondItem="2DU-C7-txT" secondAttribute="bottom" constant="25" id="0h6-vu-agV"/>
64+
<constraint firstItem="2DU-C7-txT" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" constant="10" id="3Zi-vl-ifT"/>
65+
<constraint firstAttribute="trailing" secondItem="D4r-z3-VgR" secondAttribute="trailing" constant="10" id="8FX-EW-5pg"/>
66+
<constraint firstItem="jVc-Ry-Mux" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="BOM-nf-MGN"/>
67+
<constraint firstItem="j3e-4r-Hrj" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="CX5-Ju-WcT"/>
68+
<constraint firstAttribute="trailing" secondItem="jVc-Ry-Mux" secondAttribute="trailing" constant="10" id="E24-RK-SYS"/>
69+
<constraint firstItem="iwc-9i-mzD" firstAttribute="top" secondItem="jVc-Ry-Mux" secondAttribute="bottom" constant="25" id="FbV-E5-4bq"/>
70+
<constraint firstItem="j3e-4r-Hrj" firstAttribute="top" secondItem="D4r-z3-VgR" secondAttribute="bottom" constant="25" id="I7q-Bm-tmI"/>
71+
<constraint firstItem="iwc-9i-mzD" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" constant="10" id="LGs-7X-PoD"/>
72+
<constraint firstItem="jVc-Ry-Mux" firstAttribute="top" secondItem="YA0-fO-QN5" secondAttribute="bottom" constant="25" id="OVi-6f-pSh"/>
73+
<constraint firstItem="YA0-fO-QN5" firstAttribute="top" secondItem="j3e-4r-Hrj" secondAttribute="bottom" constant="25" id="TMm-dp-PPf"/>
74+
<constraint firstAttribute="trailing" secondItem="j3e-4r-Hrj" secondAttribute="trailing" constant="10" id="aoJ-jc-axf"/>
75+
<constraint firstItem="YA0-fO-QN5" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" constant="10" id="cfc-dM-zgr"/>
76+
<constraint firstItem="2DU-C7-txT" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="dpF-im-LFt"/>
77+
<constraint firstItem="2DU-C7-txT" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" constant="25" id="eNe-xS-fNB"/>
78+
<constraint firstAttribute="trailing" secondItem="2DU-C7-txT" secondAttribute="trailing" constant="10" id="fvI-AF-ABW"/>
79+
<constraint firstAttribute="trailing" secondItem="YA0-fO-QN5" secondAttribute="trailing" constant="10" id="jMe-fZ-I5N"/>
80+
<constraint firstItem="j3e-4r-Hrj" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" constant="10" id="pdI-mt-49h"/>
81+
<constraint firstItem="jVc-Ry-Mux" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" constant="10" id="pgF-IR-2wP"/>
82+
<constraint firstItem="D4r-z3-VgR" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="qV3-x5-ReZ"/>
83+
<constraint firstAttribute="trailing" secondItem="iwc-9i-mzD" secondAttribute="trailing" constant="10" id="rUq-2v-LQq"/>
84+
<constraint firstItem="iwc-9i-mzD" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="sdU-4s-frb"/>
85+
<constraint firstItem="YA0-fO-QN5" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="ydQ-Rd-aM3"/>
86+
<constraint firstItem="D4r-z3-VgR" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" constant="10" id="zB8-SH-PnB"/>
87+
</constraints>
88+
</view>
89+
<connections>
90+
<outlet property="label1" destination="2DU-C7-txT" id="BLc-Ac-CLF"/>
91+
<outlet property="label2" destination="D4r-z3-VgR" id="Mnd-VJ-FVX"/>
92+
<outlet property="label3" destination="j3e-4r-Hrj" id="oT8-fh-LHO"/>
93+
<outlet property="label4" destination="YA0-fO-QN5" id="gcv-hp-r0f"/>
94+
<outlet property="label5" destination="jVc-Ry-Mux" id="zLJ-FG-LLb"/>
95+
<outlet property="label6" destination="iwc-9i-mzD" id="Wg5-kU-dZC"/>
96+
</connections>
97+
</viewController>
98+
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
99+
</objects>
100+
</scene>
101+
</scenes>
102+
</document>
File renamed without changes.

Demo/ViewController.swift

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
//
2+
// ViewController.swift
3+
// Demo
4+
//
5+
// Created by 郜宇 on 2017/6/13.
6+
// Copyright © 2017年 Loopeer. All rights reserved.
7+
//
8+
9+
import UIKit
10+
import AttributedStringWrapper
11+
12+
class ViewController: UIViewController {
13+
14+
@IBOutlet weak var label1: UILabel!
15+
@IBOutlet weak var label2: UILabel!
16+
@IBOutlet weak var label3: UILabel!
17+
@IBOutlet weak var label4: UILabel!
18+
@IBOutlet weak var label5: UILabel!
19+
@IBOutlet weak var label6: UILabel!
20+
21+
override func viewDidLoad() {
22+
super.viewDidLoad()
23+
24+
let content = "A view controller is tightly bound to the views it manages and takes part in the responder chain used to handle events."
25+
26+
27+
// 1. shadow: you can set range, default allRange
28+
label1.attributedText = content.toAttributed.shadow {
29+
$0.shadowColor = UIColor.red
30+
$0.shadowOffset = CGSize(width: 3, height: 3)
31+
$0.shadowBlurRadius = 2.0
32+
}.rawValue
33+
34+
35+
36+
// 2. paragraphStyle: you can set range, default allRange
37+
label2.attributedText = content.toAttributed.paragraph {
38+
$0.alignment = .center
39+
$0.lineSpacing = 8.0
40+
}.rawValue
41+
42+
43+
44+
// 3. underLine: you can set range, default allRange
45+
label3.attributedText = content.toAttributed.underLine(style: [.styleDouble, .patternDot], color: UIColor.red).rawValue
46+
47+
48+
49+
// 4. strikethrough: you can set range, default allRange
50+
label4.attributedText = content.toAttributed.strikethrough(style: [.styleDouble, .patternDot], color: UIColor.red, range: NSMakeRange(0, 10)).rawValue
51+
52+
53+
54+
// strokeStyle:
55+
label5.attributedText = content.toAttributed.stroke(color: UIColor.blue, width: 2.5).rawValue
56+
57+
58+
59+
// all:
60+
label6.attributedText = content.toAttributed
61+
.underLine(style: [.styleSingle, .patternDot], color: .red, range: NSMakeRange(0, 5))
62+
.font(.systemFont(ofSize: 18), range: NSMakeRange(5, 5))
63+
.backgroundColor(.blue, range: NSMakeRange(10, 5))
64+
.foregroundColor(.purple, range: NSMakeRange(15, 5))
65+
.baselineOffset(value: 5, range: NSMakeRange(20, 5))
66+
.obliqueness(angle: 0.5, range: NSMakeRange(25, 5))
67+
.kern(padding: 0.3, range: NSMakeRange(30, 5))
68+
.expansion(value: 0.3, range: NSMakeRange(35, 5))
69+
.stroke(color: .green, width: 3, range: NSMakeRange(40, 5))
70+
.textEffect(range: NSMakeRange(50, 5))
71+
.shadow{
72+
$0.shadowColor = UIColor.red
73+
$0.shadowOffset = CGSize(width: 3, height: 3)
74+
$0.shadowBlurRadius = 2.0
75+
}.rawValue
76+
}
77+
}
78+

Podfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Uncomment the next line to define a global platform for your project
2+
platform :ios, ‘8.0
3+
4+
target 'AttributedStringWrapper' do
5+
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
6+
use_frameworks!
7+
8+
# Pods for AttributedStringWrapper
9+
10+
target 'AttributedStringWrapperTests' do
11+
inherit! :search_paths
12+
# Pods for testing
13+
end
14+
15+
end
16+
17+
18+
19+
20+
target 'Demo' do
21+
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
22+
use_frameworks!
23+
24+
pod 'AttributedStringWrapper', path: '.'
25+
26+
27+
# Pods for Demo
28+
29+
end

Podfile.lock

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
PODS:
2+
- AttributedStringWrapper (1.0.0)
3+
4+
DEPENDENCIES:
5+
- AttributedStringWrapper (from `.`)
6+
7+
EXTERNAL SOURCES:
8+
AttributedStringWrapper:
9+
:path: "."
10+
11+
SPEC CHECKSUMS:
12+
AttributedStringWrapper: 7398cd21da18e538bd3e04595c817834517bdaf4
13+
14+
PODFILE CHECKSUM: 6a32f415201e8b4448b70222d662ed98efb484da
15+
16+
COCOAPODS: 1.2.1

Sources/AttributedStringWrapper.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// AttributedStringWrapper.h
3+
// AttributedStringWrapper
4+
//
5+
// Created by 郜宇 on 2017/6/13.
6+
// Copyright © 2017年 Loopeer. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
//! Project version number for AttributedStringWrapper.
12+
FOUNDATION_EXPORT double AttributedStringWrapperVersionNumber;
13+
14+
//! Project version string for AttributedStringWrapper.
15+
FOUNDATION_EXPORT const unsigned char AttributedStringWrapperVersionString[];
16+
17+
// In this header, you should import all the public headers of your framework using statements like #import <AttributedStringWrapper/PublicHeader.h>
18+
19+

0 commit comments

Comments
 (0)