Skip to content

Commit

Permalink
Merge branch 'phpmaple-swift4.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethTsang committed Sep 20, 2018
2 parents 7081b4c + 451321f commit e43c010
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0
4.2
6 changes: 4 additions & 2 deletions Example/GrowingTextView.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand Down Expand Up @@ -516,6 +517,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.2;
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand All @@ -537,7 +539,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -558,7 +560,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
2 changes: 1 addition & 1 deletion Example/GrowingTextView/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
Expand Down
14 changes: 7 additions & 7 deletions Example/GrowingTextView/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<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">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment version="2304" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down Expand Up @@ -124,10 +124,10 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="r6k-Bt-gaF">
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="r6k-Bt-gaF">
<rect key="frame" x="0.0" y="618" width="375" height="49"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="cJC-8p-dX3" customClass="GrowingTextView" customModule="GrowingTextView">
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="cJC-8p-dX3" customClass="GrowingTextView" customModule="GrowingTextView">
<rect key="frame" x="8" y="8" width="359" height="33"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
Expand All @@ -148,7 +148,7 @@
</subviews>
<color key="backgroundColor" white="0.92000000000000004" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="cJC-8p-dX3" firstAttribute="top" secondItem="r6k-Bt-gaF" secondAttribute="top" constant="8" id="8cx-hM-mDY"/>
<constraint firstItem="cJC-8p-dX3" firstAttribute="top" secondItem="r6k-Bt-gaF" secondAttribute="top" priority="999" constant="8" id="8cx-hM-mDY"/>
</constraints>
</view>
</subviews>
Expand Down Expand Up @@ -216,7 +216,7 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="KoN-fe-F8s" customClass="GrowingTextView" customModule="GrowingTextView">
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="KoN-fe-F8s" customClass="GrowingTextView" customModule="GrowingTextView">
<rect key="frame" x="8" y="144" width="359" height="33"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
Expand Down Expand Up @@ -260,7 +260,7 @@
<constraint firstItem="Y42-Ey-vw7" firstAttribute="leading" secondItem="MlD-Ep-TLw" secondAttribute="leading" constant="8" id="BwL-bC-XtC"/>
<constraint firstItem="MlD-Ep-TLw" firstAttribute="trailing" secondItem="Y42-Ey-vw7" secondAttribute="trailing" constant="8" id="KO9-tt-sh4"/>
<constraint firstItem="Y42-Ey-vw7" firstAttribute="top" secondItem="MlD-Ep-TLw" secondAttribute="top" constant="8" id="Wgh-YA-x0t"/>
<constraint firstItem="KoN-fe-F8s" firstAttribute="top" secondItem="bD7-AD-2Jb" secondAttribute="bottom" constant="8" id="ftY-9Y-9jj"/>
<constraint firstItem="KoN-fe-F8s" firstAttribute="top" secondItem="bD7-AD-2Jb" secondAttribute="bottom" priority="999" constant="8" id="ftY-9Y-9jj"/>
<constraint firstItem="bD7-AD-2Jb" firstAttribute="top" secondItem="Y42-Ey-vw7" secondAttribute="bottom" constant="8" id="lJV-gI-mej"/>
<constraint firstItem="MlD-Ep-TLw" firstAttribute="trailing" secondItem="bD7-AD-2Jb" secondAttribute="trailing" constant="8" id="xx1-Ba-dxI"/>
</constraints>
Expand Down
8 changes: 5 additions & 3 deletions Example/GrowingTextView/Example1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ class Example1: UIViewController {
inputToolbar.addSubview(textView)

// *** Autolayout ***
let topConstraint = textView.topAnchor.constraint(equalTo: inputToolbar.topAnchor, constant: 8)
topConstraint.priority = UILayoutPriority(999)
NSLayoutConstraint.activate([
inputToolbar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
inputToolbar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
inputToolbar.bottomAnchor.constraint(equalTo: view.bottomAnchor),
textView.topAnchor.constraint(equalTo: inputToolbar.topAnchor, constant: 8)
topConstraint
])

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

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

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

@objc private func keyboardWillChangeFrame(_ notification: Notification) {
if let endFrame = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {
if let endFrame = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {
var keyboardHeight = UIScreen.main.bounds.height - endFrame.origin.y
if #available(iOS 11, *) {
if keyboardHeight > 0 {
Expand Down
4 changes: 2 additions & 2 deletions Example/GrowingTextView/Example2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Example2: UIViewController {
textView.layer.cornerRadius = 4.0

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

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

@objc private func keyboardWillChangeFrame(_ notification: Notification) {
if let endFrame = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {
if let endFrame = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {
var keyboardHeight = UIScreen.main.bounds.height - endFrame.origin.y
if #available(iOS 11, *) {
if keyboardHeight > 0 {
Expand Down
6 changes: 4 additions & 2 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion GrowingTextView.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

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

# This description is used to generate tags and improve search results.
Expand Down
8 changes: 4 additions & 4 deletions Pod/Classes/GrowingTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ open class GrowingTextView: UITextView {
private func commonInit() {
contentMode = .redraw
associateConstraints()
NotificationCenter.default.addObserver(self, selector: #selector(textDidChange), name: .UITextViewTextDidChange, object: self)
NotificationCenter.default.addObserver(self, selector: #selector(textDidEndEditing), name: .UITextViewTextDidEndEditing, object: self)
NotificationCenter.default.addObserver(self, selector: #selector(textDidChange), name: UITextView.textDidChangeNotification, object: self)
NotificationCenter.default.addObserver(self, selector: #selector(textDidEndEditing), name: UITextView.textDidEndEditingNotification, object: self)
}

deinit {
NotificationCenter.default.removeObserver(self)
}

open override var intrinsicContentSize: CGSize {
return CGSize(width: UIViewNoIntrinsicMetric, height: 30)
return CGSize(width: UIView.noIntrinsicMetric, height: 30)
}

private func associateConstraints() {
Expand Down Expand Up @@ -153,7 +153,7 @@ open class GrowingTextView: UITextView {
// Otherwise user placeholder and inherit `text` attributes
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.alignment = textAlignment
var attributes: [NSAttributedStringKey: Any] = [
var attributes: [NSAttributedString.Key: Any] = [
.foregroundColor: placeholderColor,
.paragraphStyle: paragraphStyle
]
Expand Down
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ iOS 8.0 or above
GrowingTextView is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:

Swift 4<br>
Swift 4.2<br>

```ruby
pod 'GrowingTextView', '~> 0.6'
```

Swift 4.1<br>

```ruby
pod 'GrowingTextView', '~> 0.5'
Expand All @@ -41,7 +47,13 @@ GrowingTextView is also available through
[Carthage](https://github.com/Carthage/Carthage). To install it, add the following
line to your Cartfile:

Swift 4<br>
Swift 4.2<br>

```ruby
github "KennethTsang/GrowingTextView" ~> 0.6
```

Swift 4.1<br>

```ruby
github "KennethTsang/GrowingTextView" ~> 0.5
Expand Down

0 comments on commit e43c010

Please sign in to comment.