Skip to content

Commit e43c010

Browse files
committed
Merge branch 'phpmaple-swift4.2'
2 parents 7081b4c + 451321f commit e43c010

File tree

11 files changed

+51
-25
lines changed

11 files changed

+51
-25
lines changed

.swift-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.0
1+
4.2

Example/GrowingTextView.xcodeproj/project.pbxproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@
469469
ONLY_ACTIVE_ARCH = YES;
470470
SDKROOT = iphoneos;
471471
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
472+
SWIFT_VERSION = 4.2;
472473
};
473474
name = Debug;
474475
};
@@ -516,6 +517,7 @@
516517
MTL_ENABLE_DEBUG_INFO = NO;
517518
SDKROOT = iphoneos;
518519
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
520+
SWIFT_VERSION = 4.2;
519521
VALIDATE_PRODUCT = YES;
520522
};
521523
name = Release;
@@ -537,7 +539,7 @@
537539
PRODUCT_NAME = "$(TARGET_NAME)";
538540
PROVISIONING_PROFILE_SPECIFIER = "";
539541
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
540-
SWIFT_VERSION = 4.0;
542+
SWIFT_VERSION = 4.2;
541543
};
542544
name = Debug;
543545
};
@@ -558,7 +560,7 @@
558560
PRODUCT_NAME = "$(TARGET_NAME)";
559561
PROVISIONING_PROFILE_SPECIFIER = "";
560562
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
561-
SWIFT_VERSION = 4.0;
563+
SWIFT_VERSION = 4.2;
562564
};
563565
name = Release;
564566
};

Example/GrowingTextView/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1414
var window: UIWindow?
1515

1616

17-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
17+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
1818
// Override point for customization after application launch.
1919
return true
2020
}

Example/GrowingTextView/Base.lproj/Main.storyboard

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="fnq-Oa-kwt">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="fnq-Oa-kwt">
33
<device id="retina4_7" orientation="portrait">
44
<adaptation id="fullscreen"/>
55
</device>
66
<dependencies>
77
<deployment version="2304" identifier="iOS"/>
8-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
99
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
1010
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
1111
</dependencies>
@@ -124,10 +124,10 @@
124124
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
125125
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
126126
<subviews>
127-
<view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="r6k-Bt-gaF">
127+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="r6k-Bt-gaF">
128128
<rect key="frame" x="0.0" y="618" width="375" height="49"/>
129129
<subviews>
130-
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="cJC-8p-dX3" customClass="GrowingTextView" customModule="GrowingTextView">
130+
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="cJC-8p-dX3" customClass="GrowingTextView" customModule="GrowingTextView">
131131
<rect key="frame" x="8" y="8" width="359" height="33"/>
132132
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
133133
<fontDescription key="fontDescription" type="system" pointSize="14"/>
@@ -148,7 +148,7 @@
148148
</subviews>
149149
<color key="backgroundColor" white="0.92000000000000004" alpha="1" colorSpace="calibratedWhite"/>
150150
<constraints>
151-
<constraint firstItem="cJC-8p-dX3" firstAttribute="top" secondItem="r6k-Bt-gaF" secondAttribute="top" constant="8" id="8cx-hM-mDY"/>
151+
<constraint firstItem="cJC-8p-dX3" firstAttribute="top" secondItem="r6k-Bt-gaF" secondAttribute="top" priority="999" constant="8" id="8cx-hM-mDY"/>
152152
</constraints>
153153
</view>
154154
</subviews>
@@ -216,7 +216,7 @@
216216
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
217217
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
218218
<subviews>
219-
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="KoN-fe-F8s" customClass="GrowingTextView" customModule="GrowingTextView">
219+
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="KoN-fe-F8s" customClass="GrowingTextView" customModule="GrowingTextView">
220220
<rect key="frame" x="8" y="144" width="359" height="33"/>
221221
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
222222
<fontDescription key="fontDescription" type="system" pointSize="14"/>
@@ -260,7 +260,7 @@
260260
<constraint firstItem="Y42-Ey-vw7" firstAttribute="leading" secondItem="MlD-Ep-TLw" secondAttribute="leading" constant="8" id="BwL-bC-XtC"/>
261261
<constraint firstItem="MlD-Ep-TLw" firstAttribute="trailing" secondItem="Y42-Ey-vw7" secondAttribute="trailing" constant="8" id="KO9-tt-sh4"/>
262262
<constraint firstItem="Y42-Ey-vw7" firstAttribute="top" secondItem="MlD-Ep-TLw" secondAttribute="top" constant="8" id="Wgh-YA-x0t"/>
263-
<constraint firstItem="KoN-fe-F8s" firstAttribute="top" secondItem="bD7-AD-2Jb" secondAttribute="bottom" constant="8" id="ftY-9Y-9jj"/>
263+
<constraint firstItem="KoN-fe-F8s" firstAttribute="top" secondItem="bD7-AD-2Jb" secondAttribute="bottom" priority="999" constant="8" id="ftY-9Y-9jj"/>
264264
<constraint firstItem="bD7-AD-2Jb" firstAttribute="top" secondItem="Y42-Ey-vw7" secondAttribute="bottom" constant="8" id="lJV-gI-mej"/>
265265
<constraint firstItem="MlD-Ep-TLw" firstAttribute="trailing" secondItem="bD7-AD-2Jb" secondAttribute="trailing" constant="8" id="xx1-Ba-dxI"/>
266266
</constraints>

Example/GrowingTextView/Example1.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ class Example1: UIViewController {
3838
inputToolbar.addSubview(textView)
3939

4040
// *** Autolayout ***
41+
let topConstraint = textView.topAnchor.constraint(equalTo: inputToolbar.topAnchor, constant: 8)
42+
topConstraint.priority = UILayoutPriority(999)
4143
NSLayoutConstraint.activate([
4244
inputToolbar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
4345
inputToolbar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
4446
inputToolbar.bottomAnchor.constraint(equalTo: view.bottomAnchor),
45-
textView.topAnchor.constraint(equalTo: inputToolbar.topAnchor, constant: 8)
47+
topConstraint
4648
])
4749

4850
if #available(iOS 11, *) {
@@ -62,7 +64,7 @@ class Example1: UIViewController {
6264
}
6365

6466
// *** Listen to keyboard show / hide ***
65-
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillChangeFrame), name: NSNotification.Name.UIKeyboardWillChangeFrame, object: nil)
67+
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillChangeFrame), name: UIResponder.keyboardWillChangeFrameNotification, object: nil)
6668

6769
// *** Hide keyboard when tapping outside ***
6870
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(tapGestureHandler))
@@ -74,7 +76,7 @@ class Example1: UIViewController {
7476
}
7577

7678
@objc private func keyboardWillChangeFrame(_ notification: Notification) {
77-
if let endFrame = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {
79+
if let endFrame = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {
7880
var keyboardHeight = UIScreen.main.bounds.height - endFrame.origin.y
7981
if #available(iOS 11, *) {
8082
if keyboardHeight > 0 {

Example/GrowingTextView/Example2.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Example2: UIViewController {
2222
textView.layer.cornerRadius = 4.0
2323

2424
// *** Listen to keyboard show / hide ***
25-
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillChangeFrame), name: NSNotification.Name.UIKeyboardWillChangeFrame, object: nil)
25+
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillChangeFrame), name: UIResponder.keyboardWillChangeFrameNotification, object: nil)
2626

2727
// *** Hide keyboard when tapping outside ***
2828
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(tapGestureHandler))
@@ -34,7 +34,7 @@ class Example2: UIViewController {
3434
}
3535

3636
@objc private func keyboardWillChangeFrame(_ notification: Notification) {
37-
if let endFrame = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {
37+
if let endFrame = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {
3838
var keyboardHeight = UIScreen.main.bounds.height - endFrame.origin.y
3939
if #available(iOS 11, *) {
4040
if keyboardHeight > 0 {

Example/Pods/Pods.xcodeproj/project.pbxproj

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/Pods/Pods.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

GrowingTextView.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = "GrowingTextView"
11-
s.version = "0.5.6"
11+
s.version = "0.6.0"
1212
s.summary = "UITextView on Swift 3 and Swift 4. Support auto growing, placeholder and length limit."
1313

1414
# This description is used to generate tags and improve search results.

Pod/Classes/GrowingTextView.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,16 @@ open class GrowingTextView: UITextView {
5757
private func commonInit() {
5858
contentMode = .redraw
5959
associateConstraints()
60-
NotificationCenter.default.addObserver(self, selector: #selector(textDidChange), name: .UITextViewTextDidChange, object: self)
61-
NotificationCenter.default.addObserver(self, selector: #selector(textDidEndEditing), name: .UITextViewTextDidEndEditing, object: self)
60+
NotificationCenter.default.addObserver(self, selector: #selector(textDidChange), name: UITextView.textDidChangeNotification, object: self)
61+
NotificationCenter.default.addObserver(self, selector: #selector(textDidEndEditing), name: UITextView.textDidEndEditingNotification, object: self)
6262
}
6363

6464
deinit {
6565
NotificationCenter.default.removeObserver(self)
6666
}
6767

6868
open override var intrinsicContentSize: CGSize {
69-
return CGSize(width: UIViewNoIntrinsicMetric, height: 30)
69+
return CGSize(width: UIView.noIntrinsicMetric, height: 30)
7070
}
7171

7272
private func associateConstraints() {
@@ -153,7 +153,7 @@ open class GrowingTextView: UITextView {
153153
// Otherwise user placeholder and inherit `text` attributes
154154
let paragraphStyle = NSMutableParagraphStyle()
155155
paragraphStyle.alignment = textAlignment
156-
var attributes: [NSAttributedStringKey: Any] = [
156+
var attributes: [NSAttributedString.Key: Any] = [
157157
.foregroundColor: placeholderColor,
158158
.paragraphStyle: paragraphStyle
159159
]

0 commit comments

Comments
 (0)