diff --git a/CharacterText.xcodeproj/xcuserdata/natashatherobot.xcuserdatad/xcschemes/CharacterText.xcscheme b/CharacterText.xcodeproj/xcuserdata/natashatherobot.xcuserdatad/xcschemes/CharacterText.xcscheme
new file mode 100644
index 0000000..be9790f
--- /dev/null
+++ b/CharacterText.xcodeproj/xcuserdata/natashatherobot.xcuserdatad/xcschemes/CharacterText.xcscheme
@@ -0,0 +1,112 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CharacterText.xcodeproj/xcuserdata/natashatherobot.xcuserdatad/xcschemes/xcschememanagement.plist b/CharacterText.xcodeproj/xcuserdata/natashatherobot.xcuserdatad/xcschemes/xcschememanagement.plist
new file mode 100644
index 0000000..db39eac
--- /dev/null
+++ b/CharacterText.xcodeproj/xcuserdata/natashatherobot.xcuserdatad/xcschemes/xcschememanagement.plist
@@ -0,0 +1,27 @@
+
+
+
+
+ SchemeUserState
+
+ CharacterText.xcscheme
+
+ orderHint
+ 0
+
+
+ SuppressBuildableAutocreation
+
+ AF7BB31E195C749600E46AF2
+
+ primary
+
+
+ AF7BB330195C749600E46AF2
+
+ primary
+
+
+
+
+
diff --git a/CharacterText.xcworkspace/xcshareddata/CharacterText.xccheckout b/CharacterText.xcworkspace/xcshareddata/CharacterText.xccheckout
new file mode 100644
index 0000000..589c8d1
--- /dev/null
+++ b/CharacterText.xcworkspace/xcshareddata/CharacterText.xccheckout
@@ -0,0 +1,41 @@
+
+
+
+
+ IDESourceControlProjectFavoriteDictionaryKey
+
+ IDESourceControlProjectIdentifier
+ 3217EBBE-11A0-4C10-9972-D779A8AC3569
+ IDESourceControlProjectName
+ CharacterText
+ IDESourceControlProjectOriginsDictionary
+
+ B762B879E1986148CFB9935B4BCC2FFABE987B82
+ github.com:NatashaTheRobot/CharacterText.git
+
+ IDESourceControlProjectPath
+ CharacterText.xcworkspace
+ IDESourceControlProjectRelativeInstallPathDictionary
+
+ B762B879E1986148CFB9935B4BCC2FFABE987B82
+ ..
+
+ IDESourceControlProjectURL
+ github.com:NatashaTheRobot/CharacterText.git
+ IDESourceControlProjectVersion
+ 111
+ IDESourceControlProjectWCCIdentifier
+ B762B879E1986148CFB9935B4BCC2FFABE987B82
+ IDESourceControlProjectWCConfigurations
+
+
+ IDESourceControlRepositoryExtensionIdentifierKey
+ public.vcs.git
+ IDESourceControlWCCIdentifierKey
+ B762B879E1986148CFB9935B4BCC2FFABE987B82
+ IDESourceControlWCCName
+ CharacterText
+
+
+
+
diff --git a/CharacterText.xcworkspace/xcuserdata/natashatherobot.xcuserdatad/UserInterfaceState.xcuserstate b/CharacterText.xcworkspace/xcuserdata/natashatherobot.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..dc4508b
Binary files /dev/null and b/CharacterText.xcworkspace/xcuserdata/natashatherobot.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/CharacterText/Classes/CharacterLabel/CharacterLabel.swift b/CharacterText/Classes/CharacterLabel/CharacterLabel.swift
index 1d3ced1..13f7550 100644
--- a/CharacterText/Classes/CharacterLabel/CharacterLabel.swift
+++ b/CharacterText/Classes/CharacterLabel/CharacterLabel.swift
@@ -60,7 +60,7 @@ class CharacterLabel: UILabel, NSLayoutManagerDelegate {
}
set {
- let wordRange = NSMakeRange(0, newValue.utf16count)
+ let wordRange = NSMakeRange(0, newValue.utf16Count)
var attributedText = NSMutableAttributedString(string: newValue)
attributedText.addAttribute(NSForegroundColorAttributeName , value:self.textColor, range:wordRange)
attributedText.addAttribute(NSFontAttributeName , value:self.font, range:wordRange)
@@ -92,10 +92,15 @@ class CharacterLabel: UILabel, NSLayoutManagerDelegate {
}
- init(frame: CGRect) {
+ override init(frame: CGRect) {
super.init(frame: frame)
setupLayoutManager()
}
+
+ required init(coder aDecoder: NSCoder) {
+ super.init(coder: aDecoder)
+ setupLayoutManager()
+ }
override func awakeFromNib() {
super.awakeFromNib()
@@ -117,41 +122,40 @@ class CharacterLabel: UILabel, NSLayoutManagerDelegate {
func calculateTextLayers() {
characterTextLayers.removeAll(keepCapacity: false)
- if let attributedText = textStorage.string? {
-
- let wordRange = NSMakeRange(0, attributedText.utf16count);
- let attributedString = self.internalAttributedText();
- let layoutRect = layoutManager.usedRectForTextContainer(textContainer);
+ let attributedText = textStorage.string
+
+ let wordRange = NSMakeRange(0, attributedText.utf16Count)
+ let attributedString = self.internalAttributedText()
+ let layoutRect = layoutManager.usedRectForTextContainer(textContainer)
+
+ for var index = wordRange.location; index < wordRange.length+wordRange.location; index += 0 {
+ let glyphRange = NSMakeRange(index, 1);
+ let characterRange = layoutManager.characterRangeForGlyphRange(glyphRange, actualGlyphRange:nil);
+ let textContainer = layoutManager.textContainerForGlyphAtIndex(index, effectiveRange: nil)
+ var glyphRect = layoutManager.boundingRectForGlyphRange(glyphRange, inTextContainer: textContainer!)
+ var location = layoutManager.locationForGlyphAtIndex(index)
+ var kerningRange = layoutManager.rangeOfNominallySpacedGlyphsContainingIndex(index);
- for var index = wordRange.location; index < wordRange.length+wordRange.location; index += 0 {
- let glyphRange = NSMakeRange(index, 1);
- let characterRange = layoutManager.characterRangeForGlyphRange(glyphRange, actualGlyphRange:nil);
- let textContainer = layoutManager.textContainerForGlyphAtIndex(index, effectiveRange: nil);
- var glyphRect = layoutManager.boundingRectForGlyphRange(glyphRange, inTextContainer: textContainer);
- var location = layoutManager.locationForGlyphAtIndex(index);
- var kerningRange = layoutManager.rangeOfNominallySpacedGlyphsContainingIndex(index);
-
- if kerningRange.length > 1 && kerningRange.location == index {
- if countElements(characterTextLayers) > 0 {
- var previousLayer = characterTextLayers[characterTextLayers.endIndex-1]
- var frame = previousLayer.frame
- frame.size.width += CGRectGetMaxX(glyphRect)-CGRectGetMaxX(frame)
- previousLayer.frame = frame
- }
+ if kerningRange.length > 1 && kerningRange.location == index {
+ if countElements(characterTextLayers) > 0 {
+ var previousLayer = characterTextLayers[characterTextLayers.endIndex-1]
+ var frame = previousLayer.frame
+ frame.size.width += CGRectGetMaxX(glyphRect)-CGRectGetMaxX(frame)
+ previousLayer.frame = frame
}
-
-
- glyphRect.origin.y += location.y-(glyphRect.height/2)+(self.bounds.size.height/2)-(layoutRect.size.height/2);
-
-
- var textLayer = CATextLayer(frame: glyphRect, string: attributedString.attributedSubstringFromRange(characterRange));
- initialTextLayerAttributes(textLayer)
-
- layer.addSublayer(textLayer);
- characterTextLayers.append(textLayer);
-
- index += characterRange.length;
}
+
+
+ glyphRect.origin.y += location.y-(glyphRect.height/2)+(self.bounds.size.height/2)-(layoutRect.size.height/2);
+
+
+ var textLayer = CATextLayer(frame: glyphRect, string: attributedString.attributedSubstringFromRange(characterRange));
+ initialTextLayerAttributes(textLayer)
+
+ layer.addSublayer(textLayer);
+ characterTextLayers.append(textLayer);
+
+ index += characterRange.length;
}
}
@@ -160,7 +164,7 @@ class CharacterLabel: UILabel, NSLayoutManagerDelegate {
}
func internalAttributedText() -> NSMutableAttributedString! {
- let wordRange = NSMakeRange(0, textStorage.string.utf16count);
+ let wordRange = NSMakeRange(0, textStorage.string.utf16Count)
var attributedText = NSMutableAttributedString(string: textStorage.string);
attributedText.addAttribute(kCTForegroundColorAttributeName , value:self.textColor.CGColor, range:wordRange);
attributedText.addAttribute(kCTFontAttributeName , value:self.font, range:wordRange);
diff --git a/CharacterText/Classes/CharacterLabel/CharacterTextView.swift b/CharacterText/Classes/CharacterLabel/CharacterTextView.swift
index 44211b2..9060160 100644
--- a/CharacterText/Classes/CharacterLabel/CharacterTextView.swift
+++ b/CharacterText/Classes/CharacterLabel/CharacterTextView.swift
@@ -41,10 +41,15 @@ class CharacterTextView: UITextView, NSLayoutManagerDelegate {
}
- init(frame: CGRect, textContainer: NSTextContainer!) {
+ override init(frame: CGRect, textContainer: NSTextContainer!) {
super.init(frame: frame, textContainer: textContainer);
setupLayoutManager();
}
+
+ required init(coder aDecoder: NSCoder) {
+ super.init(coder: aDecoder)
+ setupLayoutManager()
+ }
override func awakeFromNib() {
super.awakeFromNib();
@@ -68,7 +73,7 @@ class CharacterTextView: UITextView, NSLayoutManagerDelegate {
let glyphRange = NSMakeRange(index, 1);
let characterRange = layoutManager.characterRangeForGlyphRange(glyphRange, actualGlyphRange:nil);
let textContainer = layoutManager.textContainerForGlyphAtIndex(index, effectiveRange: nil);
- var glyphRect = layoutManager.boundingRectForGlyphRange(glyphRange, inTextContainer: textContainer);
+ var glyphRect = layoutManager.boundingRectForGlyphRange(glyphRange, inTextContainer: textContainer!);
var location = layoutManager.locationForGlyphAtIndex(index);
var kerningRange = layoutManager.rangeOfNominallySpacedGlyphsContainingIndex(index);
diff --git a/CharacterText/Classes/Flickr/FlickrCollectionViewCell.swift b/CharacterText/Classes/Flickr/FlickrCollectionViewCell.swift
index 3a6bb19..79d56e5 100644
--- a/CharacterText/Classes/Flickr/FlickrCollectionViewCell.swift
+++ b/CharacterText/Classes/Flickr/FlickrCollectionViewCell.swift
@@ -12,10 +12,15 @@ class FlickrCollectionViewCell: UICollectionViewCell {
var photoImageView: UIImageView!
var darkenMask: UIView!
- init(frame: CGRect) {
+ override init(frame: CGRect) {
super.init(frame: frame)
initialSetup()
}
+
+ required init(coder aDecoder: NSCoder) {
+ super.init(coder: aDecoder)
+ initialSetup()
+ }
override func awakeFromNib() {
super.awakeFromNib()
diff --git a/CharacterText/Classes/Utilities/CLMLayerAnimation.swift b/CharacterText/Classes/Utilities/CLMLayerAnimation.swift
index 6a0ab0c..ea4477b 100644
--- a/CharacterText/Classes/Utilities/CLMLayerAnimation.swift
+++ b/CharacterText/Classes/Utilities/CLMLayerAnimation.swift
@@ -87,7 +87,7 @@ class CLMLayerAnimation: NSObject {
}
if animations.count > 0 {
- animationGroup = CAAnimationGroup()
+ animationGroup = CAAnimationGroup() as CAAnimationGroup
animationGroup!.animations = animations
}
diff --git a/CharacterText/Classes/ViewControllers/ViewController.swift b/CharacterText/Classes/ViewControllers/ViewController.swift
index ac17fb1..23ea3a4 100644
--- a/CharacterText/Classes/ViewControllers/ViewController.swift
+++ b/CharacterText/Classes/ViewControllers/ViewController.swift
@@ -10,7 +10,7 @@ import UIKit
class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate {
- @IBOutlet var collectionView: UICollectionView
+ @IBOutlet var collectionView: UICollectionView!
var dataArray = Array()
var characterLabel: MotionLabel!;
@@ -26,7 +26,7 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
FlickrKit.sharedFlickrKit().initializeWithAPIKey("334626934a41897193b6a0613f1c94a0", sharedSecret: "b0132e5cfd44574b")
let flickrKit = FlickrKit.sharedFlickrKit()
flickrKit.call(FKFlickrInterestingnessGetList()) { response, error in
- if response {
+ if let response = response {
var photoUrls = Array()
var photos: NSDictionary = response["photos"] as NSDictionary;
var photoArray: NSArray = photos["photo"] as NSArray;
@@ -54,13 +54,12 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
characterLabel.text = "You"
self.view.addSubview(characterLabel)
}
-
- func collectionView(collectionView: UICollectionView!, numberOfItemsInSection section: Int) -> Int {
+
+ func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return dataArray.count
}
- func collectionView(collectionView: UICollectionView!, cellForItemAtIndexPath indexPath: NSIndexPath!) -> UICollectionViewCell
- {
+ func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
var collectionViewCell : FlickrCollectionViewCell! = collectionView.dequeueReusableCellWithReuseIdentifier("FlickrCollectionViewCell", forIndexPath: indexPath) as FlickrCollectionViewCell
collectionViewCell.configure(dataArray[indexPath.row])
diff --git a/Pods/Pods.xcodeproj/xcuserdata/natashatherobot.xcuserdatad/xcschemes/Pods-FlickrKit.xcscheme b/Pods/Pods.xcodeproj/xcuserdata/natashatherobot.xcuserdatad/xcschemes/Pods-FlickrKit.xcscheme
new file mode 100644
index 0000000..1249c09
--- /dev/null
+++ b/Pods/Pods.xcodeproj/xcuserdata/natashatherobot.xcuserdatad/xcschemes/Pods-FlickrKit.xcscheme
@@ -0,0 +1,77 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Pods/Pods.xcodeproj/xcuserdata/natashatherobot.xcuserdatad/xcschemes/Pods-SDWebImage.xcscheme b/Pods/Pods.xcodeproj/xcuserdata/natashatherobot.xcuserdatad/xcschemes/Pods-SDWebImage.xcscheme
new file mode 100644
index 0000000..5c48a99
--- /dev/null
+++ b/Pods/Pods.xcodeproj/xcuserdata/natashatherobot.xcuserdatad/xcschemes/Pods-SDWebImage.xcscheme
@@ -0,0 +1,77 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Pods/Pods.xcodeproj/xcuserdata/natashatherobot.xcuserdatad/xcschemes/Pods.xcscheme b/Pods/Pods.xcodeproj/xcuserdata/natashatherobot.xcuserdatad/xcschemes/Pods.xcscheme
new file mode 100644
index 0000000..df545af
--- /dev/null
+++ b/Pods/Pods.xcodeproj/xcuserdata/natashatherobot.xcuserdatad/xcschemes/Pods.xcscheme
@@ -0,0 +1,77 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Pods/Pods.xcodeproj/xcuserdata/natashatherobot.xcuserdatad/xcschemes/xcschememanagement.plist b/Pods/Pods.xcodeproj/xcuserdata/natashatherobot.xcuserdatad/xcschemes/xcschememanagement.plist
new file mode 100644
index 0000000..31a2285
--- /dev/null
+++ b/Pods/Pods.xcodeproj/xcuserdata/natashatherobot.xcuserdatad/xcschemes/xcschememanagement.plist
@@ -0,0 +1,42 @@
+
+
+
+
+ SchemeUserState
+
+ Pods-FlickrKit.xcscheme
+
+ orderHint
+ 2
+
+ Pods-SDWebImage.xcscheme
+
+ orderHint
+ 3
+
+ Pods.xcscheme
+
+ orderHint
+ 1
+
+
+ SuppressBuildableAutocreation
+
+ 432590842CC541BEA2C5F3B6
+
+ primary
+
+
+ 5E052698215B41498BAF5177
+
+ primary
+
+
+ BCD5DF8710C248BBA0378911
+
+ primary
+
+
+
+
+