Skip to content

Commit 11ce661

Browse files
author
Oleg Gnidets
committed
Fix #21. AutoLayout crashes in the recent commits.
Update documentation.
1 parent 06b1010 commit 11ce661

29 files changed

+134
-679
lines changed

Sources/TweeActiveTextField.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,21 @@ open class TweeActiveTextField: TweeBorderedTextField {
3737

3838
// MARK: Methods
3939

40+
/// :nodoc:
4041
public override init(frame: CGRect) {
4142
super.init(frame: frame)
4243

4344
initializeSetup()
4445
}
4546

47+
/// :nodoc:
4648
public required init?(coder aDecoder: NSCoder) {
4749
super.init(coder: aDecoder)
4850

4951
initializeSetup()
5052
}
5153

54+
/// :nodoc:
5255
open override func layoutSubviews() {
5356
super.layoutSubviews()
5457

Sources/TweePlaceholderTextField.swift

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ open class TweePlaceholderTextField: UITextField {
5252
}
5353
}
5454

55+
/// The custom insets for `placeholderLabel` relative to the text field.
5556
public var placeholderInsets: UIEdgeInsets = .zero
5657

5758
/// Custom placeholder label. You can use it to style placeholder text.
@@ -96,25 +97,29 @@ open class TweePlaceholderTextField: UITextField {
9697

9798
// MARK: Methods
9899

100+
/// :nodoc:
99101
public override init(frame: CGRect) {
100102
super.init(frame: frame)
101103

102104
initializeSetup()
103105
}
104106

107+
/// :nodoc:
105108
public required init?(coder aDecoder: NSCoder) {
106109
super.init(coder: aDecoder)
107110

108111
initializeSetup()
109112
}
110113

114+
/// :nodoc:
111115
open override func awakeFromNib() {
112116
super.awakeFromNib()
113117

114118
configurePlaceholderLabel()
115119
setPlaceholderSizeImmediately()
116120
}
117121

122+
/// :nodoc:
118123
open override func layoutSubviews() {
119124
super.layoutSubviews()
120125

@@ -267,11 +272,13 @@ open class TweePlaceholderTextField: UITextField {
267272

268273
disablePlaceholderHeightConstraint()
269274

270-
placeholderLabel.bottomAnchor.constraint(equalTo: placeholderLayoutGuide.topAnchor).isActive = true
271-
272275
let centerYConstraint = placeholderLabel.centerYAnchor.constraint(equalTo: centerYAnchor)
273276
centerYConstraint.priority = .defaultHigh
274-
centerYConstraint.isActive = true
277+
278+
NSLayoutConstraint.activate([
279+
placeholderLabel.bottomAnchor.constraint(equalTo: placeholderLayoutGuide.topAnchor),
280+
centerYConstraint
281+
])
275282

276283
configurePlaceholderInsets()
277284
}
@@ -286,14 +293,20 @@ open class TweePlaceholderTextField: UITextField {
286293
}
287294

288295
private func enablePlaceholderHeightConstraint() {
289-
// guard placeholderLayoutGuide.owningView != nil else { return }
296+
guard placeholderLayoutGuide.owningView != nil else {
297+
return
298+
}
299+
290300
placeholderGuideHeightConstraint?.isActive = false
291301
placeholderGuideHeightConstraint = placeholderLayoutGuide.heightAnchor.constraint(equalTo: heightAnchor)
292302
placeholderGuideHeightConstraint?.isActive = true
293303
}
294304

295305
private func disablePlaceholderHeightConstraint() {
296-
guard placeholderLayoutGuide.owningView != nil else { return }
306+
guard placeholderLayoutGuide.owningView != nil else {
307+
return
308+
}
309+
297310
placeholderGuideHeightConstraint?.isActive = false
298311
placeholderGuideHeightConstraint = placeholderLayoutGuide.heightAnchor.constraint(equalToConstant: 0)
299312
placeholderGuideHeightConstraint?.isActive = true

TweeTextField.podspec

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

55
Pod::Spec.new do |s|
66
s.name = 'TweeTextField'
7-
s.version = '1.5.0'
7+
s.version = '1.5.1'
88
s.summary = 'Lightweight set of attributed text fields with nice animation'
99
s.description = <<-DESC
1010
This is lightweight library that provides different types of Text Fields based on your needs. I was inspired by https://uimovement.com/ui/2524/input-field-help/.

TweeTextField.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@
537537
DEVELOPMENT_TEAM = 4LZBFVML4B;
538538
INFOPLIST_FILE = "$(SRCROOT)/TweeTextField/Supporting Files/Info.plist";
539539
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
540-
PRODUCT_BUNDLE_IDENTIFIER = "com.com.tweetextfield1-sample";
540+
PRODUCT_BUNDLE_IDENTIFIER = com.oleg.ParkingScanner;
541541
PRODUCT_NAME = "$(TARGET_NAME)";
542542
PROVISIONING_PROFILE_SPECIFIER = "";
543543
SWIFT_VERSION = 4.2;
@@ -555,7 +555,7 @@
555555
DEVELOPMENT_TEAM = 4LZBFVML4B;
556556
INFOPLIST_FILE = "$(SRCROOT)/TweeTextField/Supporting Files/Info.plist";
557557
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
558-
PRODUCT_BUNDLE_IDENTIFIER = "com.com.tweetextfield1-sample";
558+
PRODUCT_BUNDLE_IDENTIFIER = com.oleg.ParkingScanner;
559559
PRODUCT_NAME = "$(TARGET_NAME)";
560560
PROVISIONING_PROFILE_SPECIFIER = "";
561561
SWIFT_VERSION = 4.2;

TweeTextField/AnimatedTextField.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import UIKit
66

77
class AnimatedTextField: TweeAttributedTextField {
8+
/// :nodoc:
89
override func awakeFromNib() {
910
super.awakeFromNib()
1011

TweeTextField/Base.lproj/Main.storyboard

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
33
<device id="retina4_7" orientation="portrait">
44
<adaptation id="fullscreen"/>
55
</device>
66
<dependencies>
77
<deployment identifier="iOS"/>
8-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
9-
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
109
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
1110
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
1211
</dependencies>
@@ -20,7 +19,7 @@
2019
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
2120
<subviews>
2221
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="BwO-Q2-dKq">
23-
<rect key="frame" x="147" y="319" width="80" height="33"/>
22+
<rect key="frame" x="147.5" y="319" width="80" height="33"/>
2423
<fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
2524
<state key="normal" title="CONFIRM">
2625
<color key="titleColor" red="0.29019609089999998" green="0.5647059083" blue="0.88627451660000001" alpha="1" colorSpace="deviceRGB"/>
@@ -178,7 +177,7 @@
178177
</constraints>
179178
</stackView>
180179
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="H4d-jf-O4s">
181-
<rect key="frame" x="109.5" y="360" width="156" height="30"/>
180+
<rect key="frame" x="109" y="360" width="157" height="30"/>
182181
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
183182
<state key="normal" title="REMOVE FIRST FIELD">
184183
<color key="titleColor" red="1" green="0.14913141730000001" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@@ -187,6 +186,16 @@
187186
<action selector="removeFirstField" destination="BYZ-38-t0r" eventType="touchUpInside" id="diE-xv-ZVH"/>
188187
</connections>
189188
</button>
189+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="edm-eE-aR2">
190+
<rect key="frame" x="128" y="398" width="119" height="30"/>
191+
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
192+
<state key="normal" title="GENERATE NEW">
193+
<color key="titleColor" red="0.29027547648214569" green="0.60931726718813639" blue="0.2638313663245116" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
194+
</state>
195+
<connections>
196+
<action selector="generateNewTextField" destination="BYZ-38-t0r" eventType="touchUpInside" id="sdR-xm-hL6"/>
197+
</connections>
198+
</button>
190199
</subviews>
191200
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
192201
<constraints>
@@ -197,6 +206,8 @@
197206
<constraint firstItem="BwO-Q2-dKq" firstAttribute="centerX" secondItem="6Tk-OE-BBY" secondAttribute="centerX" id="SrW-DF-eDg"/>
198207
<constraint firstItem="BwO-Q2-dKq" firstAttribute="top" secondItem="Wz3-0y-Vnd" secondAttribute="bottom" constant="37" id="aa8-zk-OuM"/>
199208
<constraint firstItem="Wz3-0y-Vnd" firstAttribute="top" secondItem="6Tk-OE-BBY" secondAttribute="top" constant="32" id="mAe-Bq-7kh"/>
209+
<constraint firstItem="edm-eE-aR2" firstAttribute="top" secondItem="H4d-jf-O4s" secondAttribute="bottom" constant="8" id="pOj-Pf-G1o"/>
210+
<constraint firstItem="edm-eE-aR2" firstAttribute="centerX" secondItem="H4d-jf-O4s" secondAttribute="centerX" id="vej-UN-xeQ"/>
200211
</constraints>
201212
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
202213
</view>

TweeTextField/ViewController.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ final class ViewController: UIViewController {
2121
override func viewDidLoad() {
2222
super.viewDidLoad()
2323

24+
passwordTextField.delegate = self
25+
2426
passwordTextField.text = "password"
2527
emailTextField.text = "text"
2628
}
@@ -35,6 +37,17 @@ final class ViewController: UIViewController {
3537
emailTextField.text = "Issue #8"
3638
}
3739

40+
@IBAction private func generateNewTextField() {
41+
let newField = TweeAttributedTextField()
42+
stackView.addArrangedSubview(newField)
43+
44+
newField.heightAnchor.constraint(equalToConstant: emailTextField.frame.height).isActive = true
45+
46+
newField.borderStyle = .roundedRect
47+
newField.text = "Newly generated"
48+
newField.tweePlaceholder = "\(Date().description)"
49+
}
50+
3851
@IBAction private func emailBeginEditing(_ sender: TweeAttributedTextField) {
3952
emailTextField.hideInfo()
4053
}
@@ -47,3 +60,9 @@ final class ViewController: UIViewController {
4760
sender.showInfo("Email address is incorrect. Check it out")
4861
}
4962
}
63+
64+
extension ViewController: UITextFieldDelegate {
65+
func textFieldShouldClear(_ textField: UITextField) -> Bool {
66+
return false
67+
}
68+
}

docs/Classes.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<a class="header-link" href="index.html">
2424
TweeTextField Docs
2525
</a>
26-
(70% documented)
26+
(100% documented)
2727
</p>
2828

2929
<p class="header-col--secondary">
@@ -224,8 +224,8 @@ <h4>Declaration</h4>
224224
</article>
225225
</div>
226226
<section class="footer">
227-
<p>&copy; 2018 <a class="link" href="https://github.com/oleghnidets" target="_blank" rel="external">Oleg Hnidets</a>. All rights reserved. (Last updated: 2018-10-02)</p>
228-
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
227+
<p>&copy; 2018 <a class="link" href="https://github.com/oleghnidets" target="_blank" rel="external">Oleg Hnidets</a>. All rights reserved. (Last updated: 2018-11-05)</p>
228+
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.4</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
229229
</section>
230230
</body>
231231
</div>

docs/Classes/TweeActiveTextField.html

Lines changed: 3 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<a class="header-link" href="../index.html">
2424
TweeTextField Docs
2525
</a>
26-
(70% documented)
26+
(100% documented)
2727
</p>
2828

2929
<p class="header-col--secondary">
@@ -184,106 +184,14 @@ <h4>Declaration</h4>
184184
</li>
185185
</ul>
186186
</div>
187-
<div class="task-group">
188-
<div class="task-name-container">
189-
<a name="/Methods"></a>
190-
<a name="//apple_ref/swift/Section/Methods" class="dashAnchor"></a>
191-
<a href="#/Methods">
192-
<h3 class="section-name">Methods</h3>
193-
</a>
194-
</div>
195-
<ul class="item-container">
196-
<li class="item">
197-
<div>
198-
<code>
199-
<a name="/c:@M@TweeTextField@objc(cs)TweeActiveTextField(im)initWithFrame:"></a>
200-
<a name="//apple_ref/swift/Method/init(frame:)" class="dashAnchor"></a>
201-
<a class="token" href="#/c:@M@TweeTextField@objc(cs)TweeActiveTextField(im)initWithFrame:">init(frame:)</a>
202-
</code>
203-
</div>
204-
<div class="height-container">
205-
<div class="pointer-container"></div>
206-
<section class="section">
207-
<div class="pointer"></div>
208-
<div class="abstract">
209-
<p>Undocumented</p>
210-
211-
</div>
212-
<div class="declaration">
213-
<h4>Declaration</h4>
214-
<div class="language">
215-
<p class="aside-title">Swift</p>
216-
<pre class="highlight swift"><code><span class="kd">public</span> <span class="k">override</span> <span class="nf">init</span><span class="p">(</span><span class="nv">frame</span><span class="p">:</span> <span class="kt">CGRect</span><span class="p">)</span></code></pre>
217-
218-
</div>
219-
</div>
220-
</section>
221-
</div>
222-
</li>
223-
<li class="item">
224-
<div>
225-
<code>
226-
<a name="/c:@M@TweeTextField@objc(cs)TweeActiveTextField(im)initWithCoder:"></a>
227-
<a name="//apple_ref/swift/Method/init(coder:)" class="dashAnchor"></a>
228-
<a class="token" href="#/c:@M@TweeTextField@objc(cs)TweeActiveTextField(im)initWithCoder:">init(coder:)</a>
229-
</code>
230-
</div>
231-
<div class="height-container">
232-
<div class="pointer-container"></div>
233-
<section class="section">
234-
<div class="pointer"></div>
235-
<div class="abstract">
236-
<p>Undocumented</p>
237-
238-
</div>
239-
<div class="declaration">
240-
<h4>Declaration</h4>
241-
<div class="language">
242-
<p class="aside-title">Swift</p>
243-
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">required</span> <span class="nf">init</span><span class="p">?(</span><span class="n">coder</span> <span class="nv">aDecoder</span><span class="p">:</span> <span class="kt">NSCoder</span><span class="p">)</span></code></pre>
244-
245-
</div>
246-
</div>
247-
</section>
248-
</div>
249-
</li>
250-
<li class="item">
251-
<div>
252-
<code>
253-
<a name="/c:@M@TweeTextField@objc(cs)TweeActiveTextField(im)layoutSubviews"></a>
254-
<a name="//apple_ref/swift/Method/layoutSubviews()" class="dashAnchor"></a>
255-
<a class="token" href="#/c:@M@TweeTextField@objc(cs)TweeActiveTextField(im)layoutSubviews">layoutSubviews()</a>
256-
</code>
257-
</div>
258-
<div class="height-container">
259-
<div class="pointer-container"></div>
260-
<section class="section">
261-
<div class="pointer"></div>
262-
<div class="abstract">
263-
<p>Undocumented</p>
264-
265-
</div>
266-
<div class="declaration">
267-
<h4>Declaration</h4>
268-
<div class="language">
269-
<p class="aside-title">Swift</p>
270-
<pre class="highlight swift"><code><span class="kd">open</span> <span class="k">override</span> <span class="kd">func</span> <span class="nf">layoutSubviews</span><span class="p">()</span></code></pre>
271-
272-
</div>
273-
</div>
274-
</section>
275-
</div>
276-
</li>
277-
</ul>
278-
</div>
279187
</div>
280188
</section>
281189

282190
</article>
283191
</div>
284192
<section class="footer">
285-
<p>&copy; 2018 <a class="link" href="https://github.com/oleghnidets" target="_blank" rel="external">Oleg Hnidets</a>. All rights reserved. (Last updated: 2018-10-02)</p>
286-
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
193+
<p>&copy; 2018 <a class="link" href="https://github.com/oleghnidets" target="_blank" rel="external">Oleg Hnidets</a>. All rights reserved. (Last updated: 2018-11-05)</p>
194+
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.4</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
287195
</section>
288196
</body>
289197
</div>

0 commit comments

Comments
 (0)