Fix crash of setting super.placeholder

This commit is contained in:
Gunay Mert Karadogan
2015-07-21 11:18:33 +02:00
parent 267a64bfb9
commit 6a3ea61e4e
2 changed files with 5 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "ParkedTextField"
s.version = "0.1.0"
s.version = "0.1.1"
s.summary = "A UITextField subclass with an appended constant text"
s.homepage = "https://github.com/gmertk/ParkedTextField"
s.screenshots = "https://dl.dropboxusercontent.com/u/4397140/pod-screenshots/ParkedTextField.gif"

View File

@@ -86,8 +86,10 @@ public class ParkedTextField: UITextField {
if let placeholder = placeholder {
let attributedString = NSMutableAttributedString(string: placeholder)
let parkedTextRange = NSMakeRange(count(placeholderText), count(parkedText))
attributedString.addAttributes(parkedTextAttributes, range: parkedTextRange)
attributedPlaceholder = attributedString
if placeholder.hasSuffix(parkedText) {
attributedString.addAttributes(parkedTextAttributes, range: parkedTextRange)
attributedPlaceholder = attributedString
}
}
}
}