Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ca23f66
Showing
18 changed files
with
1,044 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Xcode | ||
|
||
build/ | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
xcuserdata | ||
*.xccheckout | ||
*.moved-aside | ||
DerivedData | ||
*.hmap | ||
*.ipa | ||
*.xcuserstate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// AppDelegate.swift | ||
// KMPlaceholderTextView | ||
// | ||
// Created by Zhouqi Mo on 3/4/15. | ||
// Copyright (c) 2015 Zhouqi Mo. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
@UIApplicationMain | ||
class AppDelegate: UIResponder, UIApplicationDelegate { | ||
|
||
var window: UIWindow? | ||
|
||
|
||
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { | ||
// Override point for customization after application launch. | ||
return true | ||
} | ||
|
||
func applicationWillResignActive(application: UIApplication) { | ||
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. | ||
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. | ||
} | ||
|
||
func applicationDidEnterBackground(application: UIApplication) { | ||
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. | ||
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. | ||
} | ||
|
||
func applicationWillEnterForeground(application: UIApplication) { | ||
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. | ||
} | ||
|
||
func applicationDidBecomeActive(application: UIApplication) { | ||
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. | ||
} | ||
|
||
func applicationWillTerminate(application: UIApplication) { | ||
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. | ||
} | ||
|
||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6214" systemVersion="14A314h" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES"> | ||
<dependencies> | ||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6207"/> | ||
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/> | ||
</dependencies> | ||
<objects> | ||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/> | ||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> | ||
<view contentMode="scaleToFill" id="iN0-l3-epB"> | ||
<rect key="frame" x="0.0" y="0.0" width="480" height="480"/> | ||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
<subviews> | ||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" Copyright (c) 2015 Zhouqi Mo. All rights reserved." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye"> | ||
<rect key="frame" x="20" y="439" width="441" height="21"/> | ||
<fontDescription key="fontDescription" type="system" pointSize="17"/> | ||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/> | ||
<nil key="highlightedColor"/> | ||
</label> | ||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="KMPlaceholderTextView" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX"> | ||
<rect key="frame" x="20" y="140" width="441" height="43"/> | ||
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/> | ||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/> | ||
<nil key="highlightedColor"/> | ||
</label> | ||
</subviews> | ||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> | ||
<constraints> | ||
<constraint firstItem="kId-c2-rCX" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="bottom" multiplier="1/3" constant="1" id="5cJ-9S-tgC"/> | ||
<constraint firstAttribute="centerX" secondItem="kId-c2-rCX" secondAttribute="centerX" id="Koa-jz-hwk"/> | ||
<constraint firstAttribute="bottom" secondItem="8ie-xW-0ye" secondAttribute="bottom" constant="20" id="Kzo-t9-V3l"/> | ||
<constraint firstItem="8ie-xW-0ye" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="MfP-vx-nX0"/> | ||
<constraint firstAttribute="centerX" secondItem="8ie-xW-0ye" secondAttribute="centerX" id="ZEH-qu-HZ9"/> | ||
<constraint firstItem="kId-c2-rCX" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="fvb-Df-36g"/> | ||
</constraints> | ||
<nil key="simulatedStatusBarMetrics"/> | ||
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/> | ||
<point key="canvasLocation" x="548" y="455"/> | ||
</view> | ||
</objects> | ||
</document> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6254" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="hrq-b9-1Fg"> | ||
<dependencies> | ||
<deployment identifier="iOS"/> | ||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/> | ||
</dependencies> | ||
<scenes> | ||
<!--Placeholder Text View--> | ||
<scene sceneID="ufC-wZ-h7g"> | ||
<objects> | ||
<viewController id="vXZ-lx-hvc" customClass="ViewController" customModule="KMPlaceholderTextView" customModuleProvider="target" sceneMemberID="viewController"> | ||
<layoutGuides> | ||
<viewControllerLayoutGuide type="top" id="jyV-Pf-zRb"/> | ||
<viewControllerLayoutGuide type="bottom" id="2fi-mo-0CV"/> | ||
</layoutGuides> | ||
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS"> | ||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/> | ||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> | ||
<subviews> | ||
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="egS-fW-j6o" customClass="KMPlaceholderTextView" customModule="KMPlaceholderTextView" customModuleProvider="target"> | ||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/> | ||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> | ||
<fontDescription key="fontDescription" type="system" pointSize="14"/> | ||
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/> | ||
<userDefinedRuntimeAttributes> | ||
<userDefinedRuntimeAttribute type="string" keyPath="placeholder"> | ||
<mutableString key="value">Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.</mutableString> | ||
</userDefinedRuntimeAttribute> | ||
</userDefinedRuntimeAttributes> | ||
</textView> | ||
</subviews> | ||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> | ||
<constraints> | ||
<constraint firstItem="egS-fW-j6o" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leading" id="COc-fc-CYh"/> | ||
<constraint firstItem="egS-fW-j6o" firstAttribute="top" secondItem="kh9-bI-dsS" secondAttribute="top" id="DTZ-n2-vME"/> | ||
<constraint firstItem="egS-fW-j6o" firstAttribute="bottom" secondItem="2fi-mo-0CV" secondAttribute="top" id="HDf-rF-PqQ"/> | ||
<constraint firstAttribute="trailing" secondItem="egS-fW-j6o" secondAttribute="trailing" id="sEX-oZ-5O7"/> | ||
</constraints> | ||
</view> | ||
<navigationItem key="navigationItem" title="Placeholder Text View" id="WSB-Mt-GaG"/> | ||
<connections> | ||
<outlet property="placeholderTextView" destination="egS-fW-j6o" id="BJM-gA-Knc"/> | ||
</connections> | ||
</viewController> | ||
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/> | ||
</objects> | ||
<point key="canvasLocation" x="1462" y="332"/> | ||
</scene> | ||
<!--Navigation Controller--> | ||
<scene sceneID="aUw-G2-0lp"> | ||
<objects> | ||
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="hrq-b9-1Fg" sceneMemberID="viewController"> | ||
<toolbarItems/> | ||
<navigationBar key="navigationBar" contentMode="scaleToFill" id="v1t-vF-7OZ"> | ||
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/> | ||
<autoresizingMask key="autoresizingMask"/> | ||
</navigationBar> | ||
<nil name="viewControllers"/> | ||
<connections> | ||
<segue destination="vXZ-lx-hvc" kind="relationship" relationship="rootViewController" id="il9-i8-j9b"/> | ||
</connections> | ||
</navigationController> | ||
<placeholder placeholderIdentifier="IBFirstResponder" id="Hcr-nG-z2a" userLabel="First Responder" sceneMemberID="firstResponder"/> | ||
</objects> | ||
<point key="canvasLocation" x="774" y="332"/> | ||
</scene> | ||
</scenes> | ||
</document> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "29x29", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "29x29", | ||
"scale" : "3x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "40x40", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "40x40", | ||
"scale" : "3x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "60x60", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "60x60", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
Example/Images.xcassets/LaunchImage.launchimage/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"orientation" : "portrait", | ||
"idiom" : "iphone", | ||
"minimum-system-version" : "7.0", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"orientation" : "portrait", | ||
"idiom" : "iphone", | ||
"minimum-system-version" : "7.0", | ||
"subtype" : "retina4", | ||
"scale" : "2x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>en</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>com.mo.$(PRODUCT_NAME:rfc1034identifier)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>APPL</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleSignature</key> | ||
<string>????</string> | ||
<key>CFBundleVersion</key> | ||
<string>1</string> | ||
<key>LSRequiresIPhoneOS</key> | ||
<true/> | ||
<key>UILaunchStoryboardName</key> | ||
<string>LaunchScreen</string> | ||
<key>UIMainStoryboardFile</key> | ||
<string>Main</string> | ||
<key>UIRequiredDeviceCapabilities</key> | ||
<array> | ||
<string>armv7</string> | ||
</array> | ||
<key>UISupportedInterfaceOrientations</key> | ||
<array> | ||
<string>UIInterfaceOrientationPortrait</string> | ||
<string>UIInterfaceOrientationLandscapeLeft</string> | ||
<string>UIInterfaceOrientationLandscapeRight</string> | ||
</array> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// | ||
// ViewController.swift | ||
// KMPlaceholderTextView | ||
// | ||
// Created by Zhouqi Mo on 3/4/15. | ||
// Copyright (c) 2015 Zhouqi Mo. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
class ViewController: UIViewController { | ||
|
||
@IBOutlet weak var placeholderTextView: KMPlaceholderTextView! | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
// Do any additional setup after loading the view. | ||
} | ||
|
||
override func viewWillAppear(animated: Bool) { | ||
super.viewWillAppear(animated) | ||
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWasShown:", name: UIKeyboardDidShowNotification, object: nil) | ||
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillBeHidden:", name: UIKeyboardWillHideNotification, object: nil) | ||
} | ||
|
||
override func viewWillDisappear(animated: Bool) { | ||
super.viewWillDisappear(animated) | ||
NSNotificationCenter.defaultCenter().removeObserver(self, name: UIKeyboardDidShowNotification, object: nil) | ||
NSNotificationCenter.defaultCenter().removeObserver(self, name: UIKeyboardWillHideNotification, object: nil) | ||
} | ||
|
||
func keyboardWasShown(notification: NSNotification) | ||
{ | ||
let info = notification.userInfo | ||
var kbRect = info![UIKeyboardFrameEndUserInfoKey]!.CGRectValue() | ||
kbRect = view.convertRect(kbRect, fromView: nil) | ||
|
||
var contentInsets = placeholderTextView.contentInset | ||
contentInsets.bottom = kbRect.size.height | ||
placeholderTextView.contentInset = contentInsets | ||
placeholderTextView.scrollIndicatorInsets = contentInsets | ||
} | ||
|
||
func keyboardWillBeHidden(notification: NSNotification) | ||
{ | ||
var contentInsets = placeholderTextView.contentInset | ||
contentInsets.bottom = 0.0 | ||
placeholderTextView.contentInset = contentInsets | ||
placeholderTextView.scrollIndicatorInsets = contentInsets | ||
} | ||
|
||
override func didReceiveMemoryWarning() { | ||
super.didReceiveMemoryWarning() | ||
// Dispose of any resources that can be recreated. | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Pod::Spec.new do |s| | ||
|
||
s.name = "KMPlaceholderTextView" | ||
s.version = "0.1.0" | ||
s.summary = "A UITextView subclass that adds support for multiline placeholder written in Swift." | ||
|
||
s.description = <<-DESC | ||
A UITextView subclass that adds support for multiline placeholder written in Swift. | ||
It is convenient to set the value of the placeholder property just like using UITextField. | ||
DESC | ||
|
||
s.homepage = "https://github.com/MoZhouqi/KMPlaceholderTextView" | ||
s.screenshots = "https://raw.githubusercontent.com/MoZhouqi/KMPlaceholderTextView/master/Screenshots/preview.gif" | ||
|
||
s.license = "MIT" | ||
|
||
s.author = { "Zhouqi Mo" => "mozhouqi@gmail.com" } | ||
s.social_media_url = "https://twitter.com/MoZhouqi" | ||
|
||
s.platform = :ios, "8.0" | ||
|
||
s.source = { :git => "https://github.com/MoZhouqi/KMPlaceholderTextView.git", :tag => s.version } | ||
|
||
s.source_files = "KMPlaceholderTextView/*.swift" | ||
|
||
s.frameworks = "UIKit" | ||
|
||
s.requires_arc = true | ||
|
||
end |
Oops, something went wrong.