Commit d1f9360b by Daniel Dahan

development: cleaning up Editor

parent fa08e443
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
9617B0821DFCA8CF00410F8F /* CapturePreview.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96717B0F1DBE6AF600DA84DB /* CapturePreview.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 9617B0821DFCA8CF00410F8F /* CapturePreview.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96717B0F1DBE6AF600DA84DB /* CapturePreview.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B0831DFCA8CF00410F8F /* CaptureController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96717B0E1DBE6AF600DA84DB /* CaptureController.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 9617B0831DFCA8CF00410F8F /* CaptureController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96717B0E1DBE6AF600DA84DB /* CaptureController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B0841DFCA8CF00410F8F /* Editor.swift in Headers */ = {isa = PBXBuildFile; fileRef = 961DED451DCC40C500F425B6 /* Editor.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 9617B0841DFCA8CF00410F8F /* Editor.swift in Headers */ = {isa = PBXBuildFile; fileRef = 961DED451DCC40C500F425B6 /* Editor.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B0851DFCA8CF00410F8F /* EditorController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 961DED4A1DCC546100F425B6 /* EditorController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B0861DFCA8CF00410F8F /* HeightPreset.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9626CB9A1DAD3D1D003E2611 /* HeightPreset.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 9617B0861DFCA8CF00410F8F /* HeightPreset.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9626CB9A1DAD3D1D003E2611 /* HeightPreset.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B0871DFCA8CF00410F8F /* PageTabBarController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 963FBF071D669D14008F8512 /* PageTabBarController.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 9617B0871DFCA8CF00410F8F /* PageTabBarController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 963FBF071D669D14008F8512 /* PageTabBarController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B0881DFCA8CF00410F8F /* PhotoLibrary.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96717B161DBE6B1800DA84DB /* PhotoLibrary.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 9617B0881DFCA8CF00410F8F /* PhotoLibrary.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96717B161DBE6B1800DA84DB /* PhotoLibrary.swift */; settings = {ATTRIBUTES = (Public, ); }; };
...@@ -118,7 +117,6 @@ ...@@ -118,7 +117,6 @@
965E81221DD4D5C800D61E4B /* TextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB79E1CB40DC500C806FE /* TextView.swift */; }; 965E81221DD4D5C800D61E4B /* TextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB79E1CB40DC500C806FE /* TextView.swift */; };
965E81231DD4D7C800D61E4B /* BottomTabBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7591CB40DC500C806FE /* BottomTabBar.swift */; }; 965E81231DD4D7C800D61E4B /* BottomTabBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7591CB40DC500C806FE /* BottomTabBar.swift */; };
965E81241DD4D7C800D61E4B /* Editor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 961DED451DCC40C500F425B6 /* Editor.swift */; }; 965E81241DD4D7C800D61E4B /* Editor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 961DED451DCC40C500F425B6 /* Editor.swift */; };
965E81251DD4D7C800D61E4B /* EditorController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 961DED4A1DCC546100F425B6 /* EditorController.swift */; };
965E81261DD4D7C800D61E4B /* CharacterAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = 961276621DCD8B1800A7D920 /* CharacterAttribute.swift */; }; 965E81261DD4D7C800D61E4B /* CharacterAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = 961276621DCD8B1800A7D920 /* CharacterAttribute.swift */; };
9697F7BF1D8F2572004741EC /* Divider.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96230AB71D6A520C00AF47DC /* Divider.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 9697F7BF1D8F2572004741EC /* Divider.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96230AB71D6A520C00AF47DC /* Divider.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9697F7C01D8F2572004741EC /* Material+CALayer.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96F1DC871D654FDF0025F925 /* Material+CALayer.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 9697F7C01D8F2572004741EC /* Material+CALayer.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96F1DC871D654FDF0025F925 /* Material+CALayer.swift */; settings = {ATTRIBUTES = (Public, ); }; };
...@@ -196,7 +194,6 @@ ...@@ -196,7 +194,6 @@
961276621DCD8B1800A7D920 /* CharacterAttribute.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CharacterAttribute.swift; sourceTree = "<group>"; }; 961276621DCD8B1800A7D920 /* CharacterAttribute.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CharacterAttribute.swift; sourceTree = "<group>"; };
961730591E145DE900A9A297 /* CollectionViewCard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollectionViewCard.swift; sourceTree = "<group>"; }; 961730591E145DE900A9A297 /* CollectionViewCard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollectionViewCard.swift; sourceTree = "<group>"; };
961DED451DCC40C500F425B6 /* Editor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Editor.swift; sourceTree = "<group>"; }; 961DED451DCC40C500F425B6 /* Editor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Editor.swift; sourceTree = "<group>"; };
961DED4A1DCC546100F425B6 /* EditorController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EditorController.swift; sourceTree = "<group>"; };
961E6BDE1DDA2A95004E6C93 /* Application.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Application.swift; sourceTree = "<group>"; }; 961E6BDE1DDA2A95004E6C93 /* Application.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Application.swift; sourceTree = "<group>"; };
961E6BE11DDA2AF3004E6C93 /* Screen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Screen.swift; sourceTree = "<group>"; }; 961E6BE11DDA2AF3004E6C93 /* Screen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Screen.swift; sourceTree = "<group>"; };
961EFC571D738FF600E84652 /* SnackbarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SnackbarController.swift; sourceTree = "<group>"; }; 961EFC571D738FF600E84652 /* SnackbarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SnackbarController.swift; sourceTree = "<group>"; };
...@@ -315,7 +312,6 @@ ...@@ -315,7 +312,6 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
961DED451DCC40C500F425B6 /* Editor.swift */, 961DED451DCC40C500F425B6 /* Editor.swift */,
961DED4A1DCC546100F425B6 /* EditorController.swift */,
); );
name = Editor; name = Editor;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -822,7 +818,6 @@ ...@@ -822,7 +818,6 @@
9617B0821DFCA8CF00410F8F /* CapturePreview.swift in Headers */, 9617B0821DFCA8CF00410F8F /* CapturePreview.swift in Headers */,
9617B0831DFCA8CF00410F8F /* CaptureController.swift in Headers */, 9617B0831DFCA8CF00410F8F /* CaptureController.swift in Headers */,
9617B0841DFCA8CF00410F8F /* Editor.swift in Headers */, 9617B0841DFCA8CF00410F8F /* Editor.swift in Headers */,
9617B0851DFCA8CF00410F8F /* EditorController.swift in Headers */,
9617B0861DFCA8CF00410F8F /* HeightPreset.swift in Headers */, 9617B0861DFCA8CF00410F8F /* HeightPreset.swift in Headers */,
9617B0871DFCA8CF00410F8F /* PageTabBarController.swift in Headers */, 9617B0871DFCA8CF00410F8F /* PageTabBarController.swift in Headers */,
9617B0881DFCA8CF00410F8F /* PhotoLibrary.swift in Headers */, 9617B0881DFCA8CF00410F8F /* PhotoLibrary.swift in Headers */,
...@@ -929,7 +924,6 @@ ...@@ -929,7 +924,6 @@
files = ( files = (
965E81231DD4D7C800D61E4B /* BottomTabBar.swift in Sources */, 965E81231DD4D7C800D61E4B /* BottomTabBar.swift in Sources */,
965E81241DD4D7C800D61E4B /* Editor.swift in Sources */, 965E81241DD4D7C800D61E4B /* Editor.swift in Sources */,
965E81251DD4D7C800D61E4B /* EditorController.swift in Sources */,
961E6BE21DDA2AF3004E6C93 /* Screen.swift in Sources */, 961E6BE21DDA2AF3004E6C93 /* Screen.swift in Sources */,
965E81261DD4D7C800D61E4B /* CharacterAttribute.swift in Sources */, 965E81261DD4D7C800D61E4B /* CharacterAttribute.swift in Sources */,
965E80FF1DD4D5C800D61E4B /* BottomNavigationController.swift in Sources */, 965E80FF1DD4D5C800D61E4B /* BottomNavigationController.swift in Sources */,
......
...@@ -324,8 +324,9 @@ extension Editor { ...@@ -324,8 +324,9 @@ extension Editor {
/// Prepares the keyboard notification center observers. /// Prepares the keyboard notification center observers.
fileprivate func prepareKeyboardNotificationObservers() { fileprivate func prepareKeyboardNotificationObservers() {
NotificationCenter.default.addObserver(self, selector: #selector(handleKeyboardWillShow(notification:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil) let defaultCenter = NotificationCenter.default
NotificationCenter.default.addObserver(self, selector: #selector(handleKeyboardWillHide(notification:)), name: NSNotification.Name.UIKeyboardWillHide, object: nil) defaultCenter.addObserver(self, selector: #selector(handleKeyboardWillShow(notification:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
defaultCenter.addObserver(self, selector: #selector(handleKeyboardWillHide(notification:)), name: NSNotification.Name.UIKeyboardWillHide, object: nil)
} }
} }
......
/*
* Copyright (C) 2015 - 2017, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.com>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of CosmicMind nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import UIKit
import AVFoundation
extension UIViewController {
/**
A convenience property that provides access to the EditorController.
This is the recommended method of accessing the EditorController
through child UIViewControllers.
*/
public var editorController: EditorController? {
var viewController: UIViewController? = self
while nil != viewController {
if viewController is EditorController {
return viewController as? EditorController
}
viewController = viewController?.parent
}
return nil
}
}
open class EditorController: ToolbarController {
/// A reference to the Editor instance.
@IBInspectable
open let editor = Editor()
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepare method
to initialize property values and other setup operations.
The super.prepare method should always be called immediately
when subclassing.
*/
open override func prepare() {
super.prepare()
view.backgroundColor = .white
prepareToolbar()
prepareEditor()
}
/// Prepares the toolbar.
private func prepareToolbar() {
toolbar.depthPreset = .none
}
/// Prepares editor.
private func prepareEditor() {
editor.delegate = self
}
}
extension EditorController: EditorDelegate {}
...@@ -35,6 +35,14 @@ public protocol TextViewDelegate : UITextViewDelegate {} ...@@ -35,6 +35,14 @@ public protocol TextViewDelegate : UITextViewDelegate {}
@objc(TextView) @objc(TextView)
open class TextView: UITextView { open class TextView: UITextView {
/// A boolean indicating whether the text is empty.
open var isEmpty: Bool {
return 0 == text?.utf16.count
}
/// A boolean indicating whether the text is in edit mode.
open fileprivate(set) var isEditing = true
/// A property that accesses the backing layer's background /// A property that accesses the backing layer's background
@IBInspectable @IBInspectable
open override var backgroundColor: UIColor? { open override var backgroundColor: UIColor? {
...@@ -43,56 +51,49 @@ open class TextView: UITextView { ...@@ -43,56 +51,49 @@ open class TextView: UITextView {
} }
} }
/** /// The placeholderLabel font value.
The title UILabel that is displayed when there is text. The
titleLabel text value is updated with the placeholderLabel
text value before being displayed.
*/
@IBInspectable @IBInspectable
open var titleLabel: UILabel? { open override var font: UIFont? {
didSet { didSet {
prepareTitleLabel() placeholderLabel.font = font
} }
} }
/// The color of the titleLabel text when the textView is not active. /// The placeholderLabel text value.
@IBInspectable @IBInspectable
open var titleLabelColor: UIColor? { open var placeholder: String? {
didSet { get {
titleLabel?.textColor = titleLabelColor return placeholderLabel.text
}
set(value) {
placeholderLabel.text = value
layoutSubviews()
} }
} }
/// The color of the titleLabel text when the textView is active. /// The placeholder UILabel.
@IBInspectable @IBInspectable
open var titleLabelActiveColor: UIColor? open let placeholderLabel = UILabel()
/** /// Placeholder normal text
A property that sets the distance between the textView and
titleLabel.
*/
@IBInspectable @IBInspectable
open var titleLabelAnimationDistance: CGFloat = 8 open var placeholderNormalColor = Color.darkText.others {
/// Placeholder UILabel view.
open var placeholderLabel: UILabel? {
didSet { didSet {
preparePlaceholderLabel() updatePlaceholderLabelColor()
} }
} }
open var placeholder: String? { /// Placeholder active text
get { @IBInspectable
return placeholderLabel?.text open var placeholderActiveColor = Color.blue.base {
} didSet {
set(value) { updatePlaceholderLabelColor()
placeholderLabel?.text = value
} }
} }
/// An override to the text property. /// An override to the text property.
@IBInspectable @IBInspectable
open override var text: String! { open override var text: String? {
didSet { didSet {
handleTextViewTextDidChange() handleTextViewTextDidChange()
} }
...@@ -151,11 +152,12 @@ open class TextView: UITextView { ...@@ -151,11 +152,12 @@ open class TextView: UITextView {
self.init(frame: .zero, textContainer: textContainer) self.init(frame: .zero, textContainer: textContainer)
} }
/** Denitializer. This should never be called unless you know /**
Denitializer. This should never be called unless you know
what you are doing. what you are doing.
*/ */
deinit { deinit {
removeNotificationHandlers() NotificationCenter.default.removeObserver(self)
} }
open override func layoutSubviews() { open override func layoutSubviews() {
...@@ -163,62 +165,35 @@ open class TextView: UITextView { ...@@ -163,62 +165,35 @@ open class TextView: UITextView {
layoutShape() layoutShape()
layoutShadowPath() layoutShadowPath()
placeholderLabel?.preferredMaxLayoutWidth = textContainer.size.width - textContainer.lineFragmentPadding * 2 placeholderLabel.preferredMaxLayoutWidth = textContainer.size.width - textContainer.lineFragmentPadding * 2
titleLabel?.frame.size.width = bounds.width
} }
/// Reloads necessary components when the view has changed. /// Reloads necessary components when the view has changed.
open func reload() { open func reload() {
if let p = placeholderLabel {
removeConstraints(constraints) removeConstraints(constraints)
layout(p).edges( layout(placeholderLabel).edges(
top: textContainerInset.top, top: textContainerInset.top,
left: textContainerInset.left + textContainer.lineFragmentPadding, left: textContainerInset.left + textContainer.lineFragmentPadding,
bottom: textContainerInset.bottom, bottom: textContainerInset.bottom,
right: textContainerInset.right + textContainer.lineFragmentPadding) right: textContainerInset.right + textContainer.lineFragmentPadding)
} }
}
/// Notification handler for when text editing began. /// Notification handler for when text editing began.
@objc @objc
fileprivate func handleTextViewTextDidBegin() { fileprivate func handleTextViewTextDidBegin() {
titleLabel?.textColor = titleLabelActiveColor
} }
/// Notification handler for when text changed. /// Notification handler for when text changed.
@objc @objc
fileprivate func handleTextViewTextDidChange() { fileprivate func handleTextViewTextDidChange() {
if let p = placeholderLabel { placeholderLabel.isHidden = !isEmpty
p.isHidden = !(true == text?.isEmpty)
}
guard let t = text else {
hideTitleLabel()
return
}
if 0 < t.utf16.count {
showTitleLabel()
} else {
hideTitleLabel()
}
} }
/// Notification handler for when text editing ended. /// Notification handler for when text editing ended.
@objc @objc
fileprivate func handleTextViewTextDidEnd() { fileprivate func handleTextViewTextDidEnd() {
guard let t = text else {
hideTitleLabel()
return
}
if 0 < t.utf16.count {
showTitleLabel()
} else {
hideTitleLabel()
}
titleLabel?.textColor = titleLabelColor
} }
/** /**
...@@ -233,71 +208,16 @@ open class TextView: UITextView { ...@@ -233,71 +208,16 @@ open class TextView: UITextView {
textContainerInset = .zero textContainerInset = .zero
backgroundColor = .white backgroundColor = .white
clipsToBounds = false clipsToBounds = false
removeNotificationHandlers() preparePlaceholderLabel()
prepareNotificationHandlers() prepareNotificationHandlers()
reload()
} }
/// prepares the placeholderLabel property. /// prepares the placeholderLabel property.
fileprivate func preparePlaceholderLabel() { fileprivate func preparePlaceholderLabel() {
if let v: UILabel = placeholderLabel { placeholderLabel.font = font
v.font = font placeholderLabel.textAlignment = textAlignment
v.textAlignment = textAlignment placeholderLabel.numberOfLines = 0
v.numberOfLines = 0 placeholderLabel.backgroundColor = .clear
v.backgroundColor = .clear
addSubview(v)
reload()
handleTextViewTextDidChange()
}
}
/// Prepares the titleLabel property.
fileprivate func prepareTitleLabel() {
if let v: UILabel = titleLabel {
v.isHidden = true
addSubview(v)
guard let t = text, 0 == t.utf16.count else {
v.alpha = 0
return
}
showTitleLabel()
}
}
/// Shows and animates the titleLabel property.
fileprivate func showTitleLabel() {
if let v: UILabel = titleLabel {
if v.isHidden {
if let s: String = placeholderLabel?.text {
v.text = s
}
let h: CGFloat = ceil(v.font.lineHeight)
v.frame = CGRect(x: 0, y: -h, width: bounds.width, height: h)
v.isHidden = false
UIView.animate(withDuration: 0.25, animations: { [weak self] in
if let s: TextView = self {
v.alpha = 1
v.frame.origin.y = -v.frame.height - s.titleLabelAnimationDistance
}
})
}
}
}
/// Hides and animates the titleLabel property.
fileprivate func hideTitleLabel() {
if let v: UILabel = titleLabel {
if !v.isHidden {
UIView.animate(withDuration: 0.25, animations: {
v.alpha = 0
v.frame.origin.y = -v.frame.height
}) { _ in
v.isHidden = true
}
}
}
} }
/// Prepares the Notification handlers. /// Prepares the Notification handlers.
...@@ -307,12 +227,12 @@ open class TextView: UITextView { ...@@ -307,12 +227,12 @@ open class TextView: UITextView {
defaultCenter.addObserver(self, selector: #selector(handleTextViewTextDidChange), name: NSNotification.Name.UITextViewTextDidChange, object: self) defaultCenter.addObserver(self, selector: #selector(handleTextViewTextDidChange), name: NSNotification.Name.UITextViewTextDidChange, object: self)
defaultCenter.addObserver(self, selector: #selector(handleTextViewTextDidEnd), name: NSNotification.Name.UITextViewTextDidEndEditing, object: self) defaultCenter.addObserver(self, selector: #selector(handleTextViewTextDidEnd), name: NSNotification.Name.UITextViewTextDidEndEditing, object: self)
} }
}
/// Removes the Notification handlers. extension TextView {
fileprivate func removeNotificationHandlers() { /// Updates the placeholderLabel text color.
let defaultCenter = NotificationCenter.default fileprivate func updatePlaceholderLabelColor() {
defaultCenter.removeObserver(self, name: NSNotification.Name.UITextViewTextDidBeginEditing, object: self) tintColor = placeholderActiveColor
defaultCenter.removeObserver(self, name: NSNotification.Name.UITextViewTextDidChange, object: self) placeholderLabel.textColor = isEditing ? placeholderActiveColor : placeholderNormalColor
defaultCenter.removeObserver(self, name: NSNotification.Name.UITextViewTextDidEndEditing, object: self)
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment