add UnderLineTextField

This commit is contained in:
nixzhu
2015-03-17 18:48:07 +08:00
parent 1897ab42bc
commit ca59f613ee
4 changed files with 70 additions and 15 deletions
+12
View File
@@ -34,6 +34,7 @@
502AE5271AB72D06005BD199 /* YepNetworking.swift in Sources */ = {isa = PBXBuildFile; fileRef = 502AE5261AB72D06005BD199 /* YepNetworking.swift */; };
502AE5291AB81076005BD199 /* YepService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 502AE5281AB81076005BD199 /* YepService.swift */; };
502AE52B1AB819AF005BD199 /* YepConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 502AE52A1AB819AF005BD199 /* YepConfig.swift */; };
502AE52E1AB83879005BD199 /* UnderLineTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 502AE52D1AB83879005BD199 /* UnderLineTextField.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -78,6 +79,7 @@
502AE5261AB72D06005BD199 /* YepNetworking.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = YepNetworking.swift; path = Services/YepNetworking.swift; sourceTree = "<group>"; };
502AE5281AB81076005BD199 /* YepService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = YepService.swift; path = Services/YepService.swift; sourceTree = "<group>"; };
502AE52A1AB819AF005BD199 /* YepConfig.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = YepConfig.swift; path = Configs/YepConfig.swift; sourceTree = "<group>"; };
502AE52D1AB83879005BD199 /* UnderLineTextField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = UnderLineTextField.swift; path = Views/TextFields/UnderLineTextField.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -221,6 +223,7 @@
children = (
5023DE3A1AB697A700B3EE96 /* Cells */,
502AE5221AB71C82005BD199 /* Buttons */,
502AE52F1AB8387D005BD199 /* TextFields */,
);
name = Views;
sourceTree = "<group>";
@@ -303,6 +306,14 @@
name = Configs;
sourceTree = "<group>";
};
502AE52F1AB8387D005BD199 /* TextFields */ = {
isa = PBXGroup;
children = (
502AE52D1AB83879005BD199 /* UnderLineTextField.swift */,
);
name = TextFields;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@@ -417,6 +428,7 @@
502AE51B1AB70DDB005BD199 /* WelcomeViewController.swift in Sources */,
5023DE591AB6DBC100B3EE96 /* UIImage+Yep.swift in Sources */,
5023DE2D1AB685ED00B3EE96 /* DiscoverViewController.swift in Sources */,
502AE52E1AB83879005BD199 /* UnderLineTextField.swift in Sources */,
5023DE301AB6861500B3EE96 /* ProfileViewController.swift in Sources */,
5023DE261AB6856300B3EE96 /* ConversationsViewController.swift in Sources */,
502AE5271AB72D06005BD199 /* YepNetworking.swift in Sources */,
+16 -14
View File
@@ -17,13 +17,13 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Yep" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="iri-I8-0ek">
<rect key="frame" x="272" y="114" width="57" height="48"/>
<rect key="frame" x="272" y="70" width="57" height="48"/>
<fontDescription key="fontDescription" name="HelveticaNeue-CondensedBold" family="Helvetica Neue" pointSize="40"/>
<color key="textColor" red="0.0" green="0.50196081399917603" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Grow together" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="QUK-w4-ff2">
<rect key="frame" x="258" y="172" width="85" height="18"/>
<rect key="frame" x="258" y="128" width="85" height="18"/>
<fontDescription key="fontDescription" name="HelveticaNeue-CondensedBold" family="Helvetica Neue" pointSize="15"/>
<color key="textColor" red="0.60000002384185791" green="0.60000002384185791" blue="0.60000002384185791" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
@@ -104,22 +104,13 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="What's you name?" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Pw6-yh-kid">
<rect key="frame" x="222" y="94" width="156" height="24"/>
<rect key="frame" x="222" y="50" width="156" height="24"/>
<fontDescription key="fontDescription" name="HelveticaNeue-Thin" family="Helvetica Neue" pointSize="20"/>
<color key="textColor" red="0.0" green="0.50196081399917603" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Alice, Bob" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="XiO-W9-kya">
<rect key="frame" x="200" y="138" width="200" height="30"/>
<color key="backgroundColor" red="0.80000001190000003" green="0.80000001190000003" blue="0.80000001190000003" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="width" constant="200" id="Gtp-zl-Dr7"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="qGh-nq-VYU">
<rect key="frame" x="200" y="188" width="65" height="48"/>
<rect key="frame" x="200" y="149" width="65" height="48"/>
<inset key="contentEdgeInsets" minX="15" minY="15" maxX="15" maxY="15"/>
<state key="normal" title="Back">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
@@ -129,7 +120,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="OaS-1D-Ags">
<rect key="frame" x="338" y="188" width="62" height="48"/>
<rect key="frame" x="338" y="149" width="62" height="48"/>
<inset key="contentEdgeInsets" minX="15" minY="15" maxX="15" maxY="15"/>
<state key="normal" title="Next">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
@@ -138,6 +129,17 @@
<action selector="next:" destination="wEE-7G-Hr8" eventType="touchUpInside" id="AiP-2L-Rvt"/>
</connections>
</button>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Alice, Bob" textAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="XiO-W9-kya" customClass="UnderLineTextField" customModule="Yep" customModuleProvider="target">
<rect key="frame" x="200" y="94" width="200" height="35"/>
<color key="backgroundColor" red="0.80000001190000003" green="0.80000001190000003" blue="0.80000001190000003" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="height" constant="35" id="71W-6j-sbB"/>
<constraint firstAttribute="width" constant="200" id="Gtp-zl-Dr7"/>
</constraints>
<color key="textColor" red="0.0" green="0.50196081399917603" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="20"/>
<textInputTraits key="textInputTraits"/>
</textField>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
@@ -11,7 +11,7 @@ import UIKit
class RegisterPickNameViewController: UIViewController {
@IBOutlet weak var pickNamePromptLabel: UILabel!
@IBOutlet weak var nameTextField: UITextField!
@IBOutlet weak var nameTextField: UnderLineTextField!
@IBOutlet weak var backButton: UIButton!
@IBOutlet weak var nextButton: UIButton!
@@ -0,0 +1,41 @@
//
// UnderLineTextField.swift
// Yep
//
// Created by NIX on 15/3/17.
// Copyright (c) 2015 Catch Inc. All rights reserved.
//
import UIKit
@IBDesignable
class UnderLineTextField: UITextField {
@IBInspectable var underLineColor: UIColor = UIColor.yepTintColor()
@IBInspectable var underLineWidth: CGFloat = 1
lazy var underlineLayer: CAShapeLayer = {
let layer = CAShapeLayer()
layer.lineWidth = self.underLineWidth
layer.strokeColor = self.underLineColor.CGColor
return layer
}()
override func didMoveToSuperview() {
super.didMoveToSuperview()
backgroundColor = UIColor.clearColor()
layer.addSublayer(underlineLayer)
}
override func layoutSubviews() {
super.layoutSubviews()
let path = UIBezierPath()
path.moveToPoint(CGPoint(x: 0, y: CGRectGetHeight(bounds)))
path.addLineToPoint(CGPoint(x: CGRectGetWidth(bounds), y: CGRectGetHeight(bounds)))
underlineLayer.path = path.CGPath
}
}