Skip to content

Commit e04fd30

Browse files
committed
Initial commit
0 parents  commit e04fd30

38 files changed

+3713
-0
lines changed

.gitignore

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Xcode
2+
#
3+
build/
4+
*.pbxuser
5+
!default.pbxuser
6+
*.mode1v3
7+
!default.mode1v3
8+
*.mode2v3
9+
!default.mode2v3
10+
*.perspectivev3
11+
!default.perspectivev3
12+
xcuserdata
13+
*.xccheckout
14+
*.moved-aside
15+
DerivedData
16+
*.hmap
17+
*.ipa
18+
*.xcuserstate
19+
20+
# CocoaPods
21+
#
22+
# We recommend against adding the Pods directory to your .gitignore. However
23+
# you should judge for yourself, the pros and cons are mentioned at:
24+
# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
25+
#
26+
Pods/
27+
28+
# Carthage
29+
#
30+
# Add this line if you want to avoid checking in source code from Carthage dependencies.
31+
# Carthage/Checkouts
32+
Carthage/Build

.swift-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.0

.swiftlint.yml

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
disabled_rules:
2+
- trailing_whitespace
3+
- variable_name
4+
- type_name
5+
- variable_name_min_length
6+
- type_body_length
7+
8+
#- opening_brace
9+
#- comma
10+
#- colon
11+
#- control_statement
12+
#- statement_position
13+
14+
#opt_in_rules:
15+
#- empty_count
16+
#- missing_docs
17+
18+
19+
excluded:
20+
- Pods/
21+
- Sparen/Common/Generated/
22+
- Sparen/Resources
23+
- GlobalAPIKey
24+
- _name
25+
26+
force_cast: warning
27+
28+
force_try: warning
29+
30+
function_parameter_count:
31+
- 5
32+
- 12
33+
34+
function_body_length:
35+
- 50
36+
- 120
37+
38+
cyclomatic_complexity:
39+
- 20
40+
- 60
41+
42+
line_length:
43+
- 200
44+
- 800
45+
46+
type_body_length:
47+
- 500
48+
- 1000
49+
50+
file_length:
51+
- 500
52+
- 2000
53+
54+
type_name:
55+
min_length:
56+
warning: 5
57+
error: 2
58+
max_length:
59+
warning: 40
60+
error: 60
61+
62+
variable_name:
63+
min_length:
64+
warning: 5
65+
error: 2
66+
max_length:
67+
warning: 80
68+
error: 50
69+
70+
#reporter: "csv" # reporter type (xcode, json, csv, checkstyle)

.travis.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
language: objective-c
2+
osx_image: xcode8
3+
4+
env:
5+
global:
6+
- LC_CTYPE=en_US.UTF-8
7+
- LANG=en_US.UTF-8
8+
- WORKSPACE=EVReflection.xcworkspace
9+
- IOS_FRAMEWORK_SCHEME="EVReflection iOS"
10+
- MACOS_FRAMEWORK_SCHEME="EVReflection OSX"
11+
- TVOS_FRAMEWORK_SCHEME="EVReflection TVOS"
12+
- WATCHOS_FRAMEWORK_SCHEME="EVReflection WatchOS"
13+
- IOS_SDK=iphonesimulator10.0
14+
- MACOS_SDK=macosx10.12
15+
- TVOS_SDK=appletvsimulator10.0
16+
- WATCHOS_SDK=watchsimulator3.0
17+
18+
matrix:
19+
- DESTINATION="OS=3.0,name=Apple Watch - 42mm" SCHEME="$WATCHOS_FRAMEWORK_SCHEME" SDK="$WATCHOS_SDK" RUN_TESTS="NO" BUILD_EXAMPLE="NO" POD_LINT="NO"
20+
- DESTINATION="OS=2.0,name=Apple Watch - 42mm" SCHEME="$WATCHOS_FRAMEWORK_SCHEME" SDK="$WATCHOS_SDK" RUN_TESTS="NO" BUILD_EXAMPLE="NO" POD_LINT="NO"
21+
22+
- DESTINATION="OS=10.0,name=iPhone 7 Plus" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" RUN_TESTS="YES" BUILD_EXAMPLE="YES" POD_LINT="YES"
23+
- DESTINATION="OS=9.0,name=iPhone 5" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" RUN_TESTS="YES" BUILD_EXAMPLE="YES" POD_LINT="NO"
24+
25+
- DESTINATION="OS=10.0,name=Apple TV 1080p" SCHEME="$TVOS_FRAMEWORK_SCHEME" SDK="$TVOS_SDK" RUN_TESTS="YES" BUILD_EXAMPLE="NO" POD_LINT="NO"
26+
- DESTINATION="OS=9.0,name=Apple TV 1080p" SCHEME="$TVOS_FRAMEWORK_SCHEME" SDK="$TVOS_SDK" RUN_TESTS="YES" BUILD_EXAMPLE="NO" POD_LINT="NO"
27+
28+
- DESTINATION="arch=x86_64" SCHEME="$MACOS_FRAMEWORK_SCHEME" SDK="$MACOS_SDK" RUN_TESTS="YES" BUILD_EXAMPLE="NO" POD_LINT="NO"
29+
30+
before_install:
31+
- gem install cocoapods --pre --no-rdoc --no-ri --no-document --quiet
32+
33+
script:
34+
- set -o pipefail
35+
- xcodebuild -version
36+
- xcodebuild -showsdks
37+
38+
# Build Framework in Debug and Run Tests if specified
39+
- if [ $RUN_TESTS == "YES" ]; then
40+
xcodebuild -workspace "$WORKSPACE" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Debug ONLY_ACTIVE_ARCH=NO ENABLE_TESTABILITY=YES test | xcpretty;
41+
else
42+
xcodebuild -workspace "$WORKSPACE" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Debug ONLY_ACTIVE_ARCH=NO build | xcpretty;
43+
fi
44+
45+
# Build Framework in Release and Run Tests if specified
46+
- if [ $RUN_TESTS == "YES" ]; then
47+
xcodebuild -workspace "$WORKSPACE" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Release ONLY_ACTIVE_ARCH=NO ENABLE_TESTABILITY=YES test | xcpretty;
48+
else
49+
xcodebuild -workspace "$WORKSPACE" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Release ONLY_ACTIVE_ARCH=NO build | xcpretty;
50+
fi
51+
52+
# Run `pod lib lint` if specified
53+
- if [ $POD_LINT == "YES" ]; then
54+
pod lib lint;
55+
fi
56+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
//: Playground - noun: a place where people can play.
2+
3+
// Since interaction is not working, clicking the links won't do anything.
4+
5+
import AttributedTextView
6+
import UIKit
7+
8+
// In interfacebuilder put an UITextView on the canvas and set the base class to AttributedTextView. For here we just create a new instance.
9+
var textView1: AttributedTextView = AttributedTextView()
10+
11+
// First basic test
12+
textView1.attributer =
13+
"1. ".red
14+
.append("This is the first test. ").green
15+
.append("Click on ").black
16+
.append("evict.nl").makeInteract { _ in
17+
UIApplication.shared.open(URL(string: "http://evict.nl")!, options: [:], completionHandler: { completed in })
18+
}.underline
19+
.append(" for testing links. ").black
20+
.append("Next test").underline.makeInteract { _ in
21+
print("NEXT")
22+
}
23+
.all.font(UIFont(name: "SourceSansPro-Regular", size: 16))
24+
.setLinkColor(UIColor.purple) // Does not work in playground
25+
var attributedText = textView1.attributedText // Vieuw the details for this -->
26+
27+
// You can also use the Attributer for your UILabel. You only can't use the makeInteract function
28+
let myUILabel = UILabel()
29+
myUILabel.attributedText = ("Just ".red + "some ".green + "text.".orange).string
30+
let showInPlayground = myUILabel.attributedText // Vieuw the details for this -->
31+
32+
// Some more attributes and now using + instead of .append
33+
textView1.attributer =
34+
"2. red, ".red.underline.underline(0x00ff00)
35+
+ "green, ".green.fontName("Helvetica").size(30)
36+
+ "cyan, ".cyan.size(22)
37+
+ "orange, ".orange.kern(10)
38+
+ "blue, ".blue.strikethrough(3).baselineOffset(8)
39+
+ "black.".shadow(color: UIColor.gray, offset: CGSize(width: 2, height: 3), blurRadius: 3.0)
40+
attributedText = textView1.attributedText // Vieuw the details for this -->
41+
42+
// Match or matchAll
43+
textView1.attributer = "It is this or it is that where the word is is selected".size(20)
44+
.match("is").underline.underline(UIColor.red)
45+
.matchAll("is").strikethrough(4)
46+
attributedText = textView1.attributedText // Vieuw the details for this -->
47+
48+
// Select hashtags or mentions
49+
textView1.attributer = "@test: What #hashtags do we have in @evermeer #AtributedTextView library"
50+
.matchHashtags.underline
51+
.matchMentions
52+
.makeInteract { link in
53+
UIApplication.shared.open(URL(string: "https://twitter.com\(link.replacingOccurrences(of: "@", with: ""))")!, options: [:], completionHandler: { completed in })
54+
}
55+
.setLinkColor(UIColor.red) // Does not work in playground
56+
attributedText = textView1.attributedText // Vieuw the details for this -->
57+
58+
// Select links
59+
textView1.attributer = "link to http://evict.nl and https://github.com/evermeer"
60+
.matchLinks
61+
.makeInteract { link in
62+
UIApplication.shared.open(URL(string: link)!, options: [:], completionHandler: { completed in })
63+
}
64+
attributedText = textView1.attributedText // View the details for this -->
65+
66+
67+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<playground version='5.0' target-platform='ios' display-mode='raw'>
3+
<timeline fileName='timeline.xctimeline'/>
4+
</playground>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Timeline
3+
version = "3.0">
4+
<TimelineItems>
5+
<LoggerValueHistoryTimelineItem
6+
documentLocation = "file:///Users/evermeer/Desktop/AttributedTextView/AttributedTextView.playground#CharacterRangeLen=0&amp;CharacterRangeLoc=935&amp;EndingLineNumber=24&amp;StartingLineNumber=24&amp;Timestamp=502099217.893208"
7+
selectedRepresentationIndex = "0"
8+
shouldTrackSuperviewWidth = "NO">
9+
</LoggerValueHistoryTimelineItem>
10+
<LoggerValueHistoryTimelineItem
11+
documentLocation = "file:///Users/evermeer/Desktop/AttributedTextView/AttributedTextView.playground#CharacterRangeLen=0&amp;CharacterRangeLoc=431&amp;EndingLineNumber=22&amp;StartingLineNumber=22&amp;Timestamp=502099160.903026"
12+
selectedRepresentationIndex = "0"
13+
shouldTrackSuperviewWidth = "NO">
14+
</LoggerValueHistoryTimelineItem>
15+
<LoggerValueHistoryTimelineItem
16+
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=2902&amp;EndingColumnNumber=20&amp;EndingLineNumber=37&amp;StartingColumnNumber=5&amp;StartingLineNumber=37&amp;Timestamp=502191504.301184"
17+
selectedRepresentationIndex = "0"
18+
shouldTrackSuperviewWidth = "NO">
19+
</LoggerValueHistoryTimelineItem>
20+
<LoggerValueHistoryTimelineItem
21+
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=2902&amp;EndingColumnNumber=32&amp;EndingLineNumber=37&amp;StartingColumnNumber=1&amp;StartingLineNumber=37&amp;Timestamp=502191504.301309"
22+
selectedRepresentationIndex = "0"
23+
shouldTrackSuperviewWidth = "NO">
24+
</LoggerValueHistoryTimelineItem>
25+
<LoggerValueHistoryTimelineItem
26+
documentLocation = "#CharacterRangeLen=1&amp;CharacterRangeLoc=1014&amp;EndingColumnNumber=42&amp;EndingLineNumber=24&amp;StartingColumnNumber=18&amp;StartingLineNumber=24&amp;Timestamp=502099217.8936"
27+
selectedRepresentationIndex = "0"
28+
shouldTrackSuperviewWidth = "NO">
29+
</LoggerValueHistoryTimelineItem>
30+
<LoggerValueHistoryTimelineItem
31+
documentLocation = "#CharacterRangeLen=24&amp;CharacterRangeLoc=1720&amp;EndingColumnNumber=42&amp;EndingLineNumber=39&amp;StartingColumnNumber=18&amp;StartingLineNumber=39&amp;Timestamp=502186286.817336"
32+
selectedRepresentationIndex = "0"
33+
shouldTrackSuperviewWidth = "NO">
34+
</LoggerValueHistoryTimelineItem>
35+
<LoggerValueHistoryTimelineItem
36+
documentLocation = "#CharacterRangeLen=24&amp;CharacterRangeLoc=1994&amp;EndingColumnNumber=42&amp;EndingLineNumber=43&amp;StartingColumnNumber=18&amp;StartingLineNumber=43&amp;Timestamp=502186286.817457"
37+
selectedRepresentationIndex = "0"
38+
shouldTrackSuperviewWidth = "NO">
39+
</LoggerValueHistoryTimelineItem>
40+
<LoggerValueHistoryTimelineItem
41+
documentLocation = "#CharacterRangeLen=24&amp;CharacterRangeLoc=2513&amp;EndingColumnNumber=42&amp;EndingLineNumber=53&amp;StartingColumnNumber=18&amp;StartingLineNumber=53&amp;Timestamp=502191504.301817"
42+
selectedRepresentationIndex = "0"
43+
shouldTrackSuperviewWidth = "NO">
44+
</LoggerValueHistoryTimelineItem>
45+
<LoggerValueHistoryTimelineItem
46+
documentLocation = "#CharacterRangeLen=24&amp;CharacterRangeLoc=2842&amp;EndingColumnNumber=42&amp;EndingLineNumber=63&amp;StartingColumnNumber=18&amp;StartingLineNumber=63&amp;Timestamp=502191504.301917"
47+
selectedRepresentationIndex = "0"
48+
shouldTrackSuperviewWidth = "NO">
49+
</LoggerValueHistoryTimelineItem>
50+
<LoggerValueHistoryTimelineItem
51+
documentLocation = "#CharacterRangeLen=16&amp;CharacterRangeLoc=1226&amp;EndingColumnNumber=21&amp;EndingLineNumber=29&amp;StartingColumnNumber=5&amp;StartingLineNumber=29&amp;Timestamp=502186286.817813"
52+
selectedRepresentationIndex = "0"
53+
shouldTrackSuperviewWidth = "NO">
54+
</LoggerValueHistoryTimelineItem>
55+
<LoggerValueHistoryTimelineItem
56+
documentLocation = "#CharacterRangeLen=14&amp;CharacterRangeLoc=940&amp;EndingColumnNumber=19&amp;EndingLineNumber=24&amp;StartingColumnNumber=5&amp;StartingLineNumber=24&amp;Timestamp=502192146.844647"
57+
selectedRepresentationIndex = "0"
58+
shouldTrackSuperviewWidth = "NO">
59+
</LoggerValueHistoryTimelineItem>
60+
</TimelineItems>
61+
</Timeline>

AttributedTextView.podspec

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Pod::Spec.new do |s|
2+
s.name = 'AttributedTextView'
3+
s.version = '0.1.0'
4+
s.license = { :type => "MIT", :file => "LICENSE" }
5+
s.summary = 'Easiest way to create an attributed UITextView with support for multiple links'
6+
s.homepage = 'http://evict.nl'
7+
s.social_media_url = 'https://twitter.com/evermeer'
8+
s.authors = { "Edwin Vermeer" => "[email protected]" }
9+
s.source = { :git => "https://github.com/evermeer/AttributedTextView.git", :tag => "v"+s.version.to_s }
10+
s.platforms = { :ios => "8.0", :osx => "10.10", :tvos => "9.0", :watchos => "2.0" }
11+
s.requires_arc = true
12+
13+
s.default_subspec = "Core"
14+
s.subspec "Core" do |ss|
15+
ss.source_files = "Sources/*.swift"
16+
ss.framework = "Foundation"
17+
end
18+
19+
end

0 commit comments

Comments
 (0)