Skip to content

Commit

Permalink
Merge pull request #29 from ruslanskorb/develop
Browse files Browse the repository at this point in the history
Version 8.0.0
  • Loading branch information
ruslanskorb committed Jan 20, 2024
2 parents add9816 + fb9d51a commit e10548a
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 27 deletions.
2 changes: 1 addition & 1 deletion RSKPlaceholderTextView.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'RSKPlaceholderTextView'
s.version = '7.0.0'
s.version = '8.0.0'
s.summary = 'A light-weight UITextView subclass that adds support for placeholder.'
s.homepage = 'https://github.com/ruslanskorb/RSKPlaceholderTextView'
s.license = { :type => 'Apache', :file => 'LICENSE' }
Expand Down
20 changes: 10 additions & 10 deletions RSKPlaceholderTextView.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 7.0.0;
CURRENT_PROJECT_VERSION = 8.0.0;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down Expand Up @@ -235,7 +235,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 7.0.0;
CURRENT_PROJECT_VERSION = 8.0.0;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand Down Expand Up @@ -266,10 +266,10 @@
APPLICATION_EXTENSION_API_ONLY = YES;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
CURRENT_PROJECT_VERSION = 7.0.0;
CURRENT_PROJECT_VERSION = 8.0.0;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 7.0.0;
DYLIB_CURRENT_VERSION = 7.0.0;
DYLIB_COMPATIBILITY_VERSION = 8.0.0;
DYLIB_CURRENT_VERSION = 8.0.0;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_MODULE_VERIFIER = YES;
INFOPLIST_FILE = RSKPlaceholderTextView/Info.plist;
Expand All @@ -280,7 +280,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 7.0.0;
MARKETING_VERSION = 8.0.0;
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11";
PRODUCT_BUNDLE_IDENTIFIER = com.ruslanskorb.RSKPlaceholderTextView;
Expand All @@ -298,10 +298,10 @@
APPLICATION_EXTENSION_API_ONLY = YES;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
CURRENT_PROJECT_VERSION = 7.0.0;
CURRENT_PROJECT_VERSION = 8.0.0;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 7.0.0;
DYLIB_CURRENT_VERSION = 7.0.0;
DYLIB_COMPATIBILITY_VERSION = 8.0.0;
DYLIB_CURRENT_VERSION = 8.0.0;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_MODULE_VERIFIER = YES;
INFOPLIST_FILE = RSKPlaceholderTextView/Info.plist;
Expand All @@ -312,7 +312,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 7.0.0;
MARKETING_VERSION = 8.0.0;
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11";
PRODUCT_BUNDLE_IDENTIFIER = com.ruslanskorb.RSKPlaceholderTextView;
Expand Down
59 changes: 46 additions & 13 deletions RSKPlaceholderTextView/RSKPlaceholderTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,22 @@ import UIKit
placeholderAttributes[.font] = self.font ?? UIFont.systemFont(ofSize: UIFont.systemFontSize)
}

if placeholderAttributes[.paragraphStyle] == nil {
if let paragraphStyle = placeholderAttributes[.paragraphStyle] as? NSParagraphStyle {

let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.alignment = self.textAlignment
paragraphStyle.lineBreakMode = self.textContainer.lineBreakMode
placeholderAttributes[.paragraphStyle] = paragraphStyle
if paragraphStyle.lineBreakMode != self.placeholderLineBreakMode {

let mutableParagraphStyle = NSMutableParagraphStyle()
mutableParagraphStyle.setParagraphStyle(paragraphStyle)
mutableParagraphStyle.lineBreakMode = self.placeholderLineBreakMode
placeholderAttributes[.paragraphStyle] = mutableParagraphStyle
}
}
else {

let mutableParagraphStyle = NSMutableParagraphStyle()
mutableParagraphStyle.alignment = self.textAlignment
mutableParagraphStyle.lineBreakMode = self.placeholderLineBreakMode
placeholderAttributes[.paragraphStyle] = mutableParagraphStyle
}

placeholderAttributes[.foregroundColor] = self.placeholderColor
Expand Down Expand Up @@ -70,21 +80,32 @@ import UIKit
self.font != font {

self.font = font

self.typingAttributes[.font] = font
}
if let foregroundColor = attributes[.foregroundColor] as? UIColor,
self.placeholderColor != foregroundColor {

self.placeholderColor = foregroundColor
}
if let paragraphStyle = attributes[.paragraphStyle] as? NSParagraphStyle,
self.textAlignment != paragraphStyle.alignment {

let mutableParagraphStyle = NSMutableParagraphStyle()
mutableParagraphStyle.setParagraphStyle(paragraphStyle)
if let paragraphStyle = attributes[.paragraphStyle] as? NSParagraphStyle {

self.textAlignment = paragraphStyle.alignment
self.typingAttributes[.paragraphStyle] = mutableParagraphStyle
if self.placeholderLineBreakMode != paragraphStyle.lineBreakMode {

self.placeholderLineBreakMode = paragraphStyle.lineBreakMode
}
if self.textAlignment != paragraphStyle.alignment {

self.textAlignment = paragraphStyle.alignment

let mutableTypingAttributesParagraphStyle = NSMutableParagraphStyle()
if let typingAttributesParagraphStyle = self.typingAttributes[.paragraphStyle] as? NSParagraphStyle {

mutableTypingAttributesParagraphStyle.setParagraphStyle(typingAttributesParagraphStyle)
}
mutableTypingAttributesParagraphStyle.alignment = paragraphStyle.alignment
self.typingAttributes[.paragraphStyle] = mutableTypingAttributesParagraphStyle
}
}
}
guard self.isEmpty == true else {
Expand Down Expand Up @@ -118,7 +139,7 @@ import UIKit
}
}

/// The color of the placeholder. This property applies to the entire placeholder string. The default placeholder color is `UIColor(red: 0.6, green: 0.6, blue: 0.6, alpha: 1.0)`.
/// The color of the placeholder. This property applies to the entire placeholder. The default value of this property is `UIColor(red: 0.6, green: 0.6, blue: 0.6, alpha: 1.0)`.
@IBInspectable open var placeholderColor: UIColor = UIColor(red: 0.6, green: 0.6, blue: 0.6, alpha: 1.0) {

didSet {
Expand All @@ -130,6 +151,18 @@ import UIKit
}
}

/// The technique for wrapping and truncating the placeholder. This property applies to the entire placeholder. The default value of this property is `NSLineBreakMode.byWordWrapping`.
open var placeholderLineBreakMode: NSLineBreakMode = .byWordWrapping {

didSet {

if let placeholder = self.placeholder as String? {

self.attributedPlaceholder = NSAttributedString(string: placeholder, attributes: self.placeholderAttributes)
}
}
}

// MARK: - Superclass Properties

open override var attributedText: NSAttributedString! { didSet { self.setNeedsDisplay() } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 7.0.0;
MARKETING_VERSION = 8.0.0;
PRODUCT_BUNDLE_IDENTIFIER = com.ruslanskorb.RSKPlaceholderTextViewExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -407,7 +407,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 7.0.0;
MARKETING_VERSION = 8.0.0;
PRODUCT_BUNDLE_IDENTIFIER = com.ruslanskorb.RSKPlaceholderTextViewExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>7.0.0</string>
<string>8.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down

0 comments on commit e10548a

Please sign in to comment.