Skip to content

Commit

Permalink
Merge branch 'develop/swift4'
Browse files Browse the repository at this point in the history
  • Loading branch information
khawars committed Oct 16, 2017
2 parents 1cf8531 + f6d950b commit 831b624
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 66 deletions.
8 changes: 5 additions & 3 deletions Examples/Examples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
TargetAttributes = {
C389780A1DFB1FB3009E3D81 = {
CreatedOnToolsVersion = 8.1;
LastSwiftMigration = 0810;
LastSwiftMigration = 0900;
ProvisioningStyle = Automatic;
};
};
Expand Down Expand Up @@ -336,7 +336,8 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Examples/Examples-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -351,7 +352,8 @@
PRODUCT_BUNDLE_IDENTIFIER = KSTokenView.Examples;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Examples/Examples-Bridging-Header.h";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down
14 changes: 7 additions & 7 deletions Examples/Examples/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="Am3-ke-xYS">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="Am3-ke-xYS">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13173"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down Expand Up @@ -63,7 +64,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" placeholderIntrinsicWidth="343" placeholderIntrinsicHeight="40" translatesAutoresizingMaskIntoConstraints="NO" id="EaI-oN-IeW" customClass="KSTokenView" customModule="Examples" customModuleProvider="target">
<rect key="frame" x="16" y="72" width="343" height="40"/>
<rect key="frame" x="16" y="92" width="343" height="40"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
</subviews>
Expand All @@ -88,7 +89,7 @@
<navigationController storyboardIdentifier="NavigationController" automaticallyAdjustsScrollViewInsets="NO" id="Am3-ke-xYS" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="uVx-tQ-xIj">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
Expand Down Expand Up @@ -143,17 +144,16 @@
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Change Appearance" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sW9-yn-47G">
<rect key="frame" x="20" y="171" width="158" height="21"/>
<rect key="frame" x="20" y="171" width="156.5" height="21"/>
<constraints>
<constraint firstAttribute="width" constant="158" id="6eW-Re-CEx"/>
<constraint firstAttribute="height" constant="21" id="lmC-VH-szY"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="7Ow-Qz-Onf">
<rect key="frame" x="200" y="166" width="51" height="31"/>
<rect key="frame" x="198.5" y="166" width="51" height="31"/>
<constraints>
<constraint firstAttribute="height" constant="31" id="AN3-zr-0uk"/>
<constraint firstAttribute="width" constant="49" id="Fgm-YV-RFj"/>
Expand Down
2 changes: 1 addition & 1 deletion KSTokenView.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Pod::Spec.new do |s|

# ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
s.name = "KSTokenView"
s.version = "3.1.4"
s.version = "4.0.0"
s.summary = "An iOS control for displaying multiple selections as tokens."
s.description = <<-DESC
KSTokenView is a control that displays a collection of tokens in an editable UITextField and sends messages to delegate object. It can also be used to input text from user and perform search operation asynchronously. UI can be fully custimized to look like part of your application.
Expand Down
3 changes: 1 addition & 2 deletions KSTokenView/KSToken.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,11 @@ open class KSToken : UIControl {
let rectangleStyle = NSMutableParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle
rectangleStyle.lineBreakMode = NSLineBreakMode.byTruncatingTail
rectangleStyle.alignment = NSTextAlignment.center
let rectangleFontAttributes = [NSFontAttributeName: font, NSForegroundColorAttributeName: textColor, NSParagraphStyleAttributeName: rectangleStyle] as [String : Any]
let rectangleFontAttributes = [NSAttributedStringKey.font: font, NSAttributedStringKey.foregroundColor: textColor, NSAttributedStringKey.paragraphStyle: rectangleStyle] as [NSAttributedStringKey : Any]

let maxDrawableHeight = max(rect.height , font.lineHeight)
let textHeight: CGFloat = KSUtils.getRect(rectangleTextContent as NSString, width: rect.width, height: maxDrawableHeight , font: font).size.height


let textRect = CGRect(x: rect.minX + paddingX, y: rect.minY + (maxDrawableHeight - textHeight) / 2, width: min(maxWidth, rect.width) - (paddingX*2), height: maxDrawableHeight)

rectangleTextContent.draw(in: textRect, withAttributes: rectangleFontAttributes)
Expand Down
14 changes: 8 additions & 6 deletions KSTokenView/KSTokenField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ open class KSTokenField: UITextField {
}

override open func draw(_ rect: CGRect) {
_selfFrame = rect
if (!_setupCompleted) {
_selfFrame = rect
}
_setupCompleted = true
_updateText()

Expand Down Expand Up @@ -582,8 +584,8 @@ open class KSTokenField: UITextField {
title += "\(token.title)\(_separatorText!)"
}

if (title.characters.count > 0) {
title = title.substring(with: title.characters.index(title.startIndex, offsetBy: 0)..<title.characters.index(title.endIndex, offsetBy: -_separatorText!.characters.count))
if (title.characters.count > 0) {
title = String(title[..<title.index(title.endIndex, offsetBy: -_separatorText!.characters.count)])
}

let width = KSUtils.widthOfString(title, font: font!)
Expand Down Expand Up @@ -654,14 +656,14 @@ open class KSTokenField: UITextField {
tokenFieldDelegate?.tokenFieldDidSelectToken?(token)
}

func tokenTouchDown(_ token: KSToken) {
@objc func tokenTouchDown(_ token: KSToken) {
if (selectedToken != nil) {
selectedToken?.isSelected = false
selectedToken = nil
}
}

func tokenTouchUpInside(_ token: KSToken) {
@objc func tokenTouchUpInside(_ token: KSToken) {
selectToken(token)
}

Expand All @@ -672,7 +674,7 @@ open class KSTokenField: UITextField {
return super.beginTracking(touch, with: event)
}

func tokenFieldTextDidChange(_ textField: UITextField) {
@objc func tokenFieldTextDidChange(_ textField: UITextField) {
_updatePlaceHolderVisibility()
}

Expand Down
Loading

0 comments on commit 831b624

Please sign in to comment.