Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Demo/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
TimedSilver: 9a4db36b50fe8dd2f76ec28a1d5b6f0e98f6bb30
TimedSilver: d811b891a5a3db4655bbfcb017313abfaa0e36ab

PODFILE CHECKSUM: 416a9304df26078601f30ee2451b2f3dbe8abf38

COCOAPODS: 1.2.0
COCOAPODS: 1.5.3
28 changes: 9 additions & 19 deletions Demo/TimedSilverExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@
AEBAE9391D8E8AF200CFDBD5 /* Frameworks */,
AEBAE93A1D8E8AF200CFDBD5 /* Resources */,
ED52BC296B9EF83249163349 /* [CP] Embed Pods Frameworks */,
201A5143EF5307CE6CDE43D3 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -230,28 +229,16 @@
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-TimedSilverExample-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
201A5143EF5307CE6CDE43D3 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-TimedSilverExample/Pods-TimedSilverExample-resources.sh\"\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
ED52BC296B9EF83249163349 /* [CP] Embed Pods Frameworks */ = {
Expand All @@ -260,9 +247,12 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-TimedSilverExample/Pods-TimedSilverExample-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/TimedSilver/TimedSilver.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/TimedSilver.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down Expand Up @@ -433,7 +423,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = Hilen.TimedSilverExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -446,7 +436,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = Hilen.TimedSilverExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
2 changes: 1 addition & 1 deletion Demo/TimedSilverExample/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
1 change: 1 addition & 0 deletions Demo/TimedSilverExample/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ViewController: UIViewController {
super.viewDidLoad()
print(UIViewController.ts_className)
// Do any additional setup after loading the view, typically from a nib.
self.view.backgroundColor = UIColor.red;
}

override func didReceiveMemoryWarning() {
Expand Down
4 changes: 2 additions & 2 deletions Sources/Foundation/Timer+TSBlock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ extension Timer {
/// By default, the timer is scheduled on the current run loop for the default mode.
/// Specify `runLoop` or `modes` to override these defaults.

public func ts_start(runLoop: RunLoop = RunLoop.current, modes: RunLoopMode...) {
let modes = modes.isEmpty ? [RunLoopMode.defaultRunLoopMode] : modes
public func ts_start(runLoop: RunLoop = RunLoop.current, modes: RunLoop.Mode...) {
let modes = modes.isEmpty ? [RunLoop.Mode.default] : modes

for mode in modes {
runLoop.add(self, forMode: mode)
Expand Down
6 changes: 3 additions & 3 deletions Sources/Struct/String+TSExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public extension String {
let size: CGSize = self.boundingRect(
with: constraintRect,
options: NSStringDrawingOptions.usesLineFragmentOrigin,
attributes: [NSAttributedStringKey.font: font],
attributes: [NSAttributedString.Key.font: font],
context: nil
).size
return size
Expand All @@ -48,7 +48,7 @@ public extension String {
let boundingBox = self.boundingRect(
with: constraintRect,
options: .usesLineFragmentOrigin,
attributes: [NSAttributedStringKey.font: font],
attributes: [NSAttributedString.Key.font: font],
context: nil)
return boundingBox.height
}
Expand All @@ -65,7 +65,7 @@ public extension String {
let boundingBox = self.boundingRect(
with: constraintRect,
options: .usesLineFragmentOrigin,
attributes: [NSAttributedStringKey.font: font],
attributes: [NSAttributedString.Key.font: font],
context: nil)
return boundingBox.width
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/UIKit/UIButton+TSExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public extension UIButton {
- parameter color: color
- parameter forState: UIControlState
*/
public func ts_setBackgroundColor(_ color: UIColor, forState: UIControlState) {
public func ts_setBackgroundColor(_ color: UIColor, forState: UIControl.State) {
UIGraphicsBeginImageContext(CGSize(width: 1, height: 1))
UIGraphicsGetCurrentContext()?.setFillColor(color.cgColor)
UIGraphicsGetCurrentContext()?.fill(CGRect(x: 0, y: 0, width: 1, height: 1))
Expand Down
4 changes: 2 additions & 2 deletions Sources/UIKit/UIButton+TSTouchArea.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ extension UIButton {
}

let relativeFrame = self.bounds
let hitFrame = UIEdgeInsetsInsetRect(relativeFrame, self.ts_touchInsets)

// let hitFrame = UIEdgeInsetsInsetRect(relativeFrame, self.ts_touchInsets)
let hitFrame = relativeFrame.inset(by: self.ts_touchInsets)
return hitFrame.contains(point)
}
}
Expand Down
12 changes: 6 additions & 6 deletions Sources/UIKit/UICollectionView+TSGeneric.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public extension UICollectionView {
func ts_registerHeaderNib<T: UICollectionReusableView>(_ aClass: T.Type) {
let name = String(describing: aClass)
let nib = UINib(nibName: name, bundle: nil)
self.register(nib, forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: name)
self.register(nib, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: name)
}

/**
Expand All @@ -68,7 +68,7 @@ public extension UICollectionView {
*/
func ts_registerHeaderClass<T: UICollectionReusableView>(_ aClass: T.Type) {
let name = String(describing: aClass)
self.register(aClass, forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: name)
self.register(aClass, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: name)
}

/**
Expand All @@ -82,7 +82,7 @@ public extension UICollectionView {
func ts_dequeueReusableHeader<T: UICollectionReusableView>(_ aClass: T.Type, forIndexPath indexPath: IndexPath) -> T! {
let name = String(describing: aClass)
guard let view = dequeueReusableSupplementaryView(
ofKind: UICollectionElementKindSectionHeader,
ofKind: UICollectionView.elementKindSectionHeader,
withReuseIdentifier: name,
for: indexPath) as? T else {
fatalError("\(name) is not registed")
Expand All @@ -99,7 +99,7 @@ public extension UICollectionView {
func ts_registerFooterNib<T: UICollectionReusableView>(_ aClass: T.Type) {
let name = String(describing: aClass)
let nib = UINib(nibName: name, bundle: nil)
self.register(nib, forSupplementaryViewOfKind: UICollectionElementKindSectionFooter, withReuseIdentifier: name)
self.register(nib, forSupplementaryViewOfKind: UICollectionView.elementKindSectionFooter, withReuseIdentifier: name)
}

/**
Expand All @@ -109,7 +109,7 @@ public extension UICollectionView {
*/
func ts_registerFooterClass<T: UICollectionReusableView>(_ aClass: T.Type) {
let name = String(describing: aClass)
self.register(aClass, forSupplementaryViewOfKind: UICollectionElementKindSectionFooter, withReuseIdentifier: name)
self.register(aClass, forSupplementaryViewOfKind: UICollectionView.elementKindSectionFooter, withReuseIdentifier: name)
}

/**
Expand All @@ -123,7 +123,7 @@ public extension UICollectionView {
func ts_dequeueReusableFooter<T: UICollectionReusableView>(_ aClass: T.Type, forIndexPath indexPath: IndexPath) -> T! {
let name = String(describing: aClass)
guard let view = dequeueReusableSupplementaryView(
ofKind: UICollectionElementKindSectionFooter,
ofKind: UICollectionView.elementKindSectionFooter,
withReuseIdentifier: name,
for: indexPath) as? T else {
fatalError("\(name) is not registed")
Expand Down
2 changes: 1 addition & 1 deletion Sources/UIKit/UIControl+TSExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public extension UIControl {
- parameter events: UIControlEvents
- parameter callback: callback
*/
func ts_addEventHandler(forControlEvent controlEvent: UIControlEvents, handler callback: @escaping () -> Void) {
func ts_addEventHandler(forControlEvent controlEvent: UIControl.Event, handler callback: @escaping () -> Void) {
let wrapper = TSClosureWrapper(callback: callback)
addTarget(wrapper, action:#selector(TSClosureWrapper.invoke), for: controlEvent)
objc_setAssociatedObject(self, &AssociatedClosure, wrapper, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
Expand Down
11 changes: 9 additions & 2 deletions Sources/UIKit/UIControl+TSSound.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,20 @@ extension UIControl {
- parameter name: music name
- parameter controlEvent: controlEvent
*/
public func ts_addSoundName(_ name: String, forControlEvent controlEvent: UIControlEvents) {
public func ts_addSoundName(_ name: String, forControlEvent controlEvent: UIControl.Event) {
let oldSoundKey: String = "\(controlEvent)"
let oldSound: AVAudioPlayer = self.ts_sounds[oldSoundKey]!
let selector = NSSelectorFromString("play")
self.removeTarget(oldSound, action: selector, for: controlEvent)
do {
try AVAudioSession.sharedInstance().setCategory("AVAudioSessionCategoryAmbient")
if #available(iOS 10.0, *) {
try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.ambient, mode: AVAudioSession.Mode.default, options: AVAudioSession.CategoryOptions.defaultToSpeaker)
} else {
// Fallback on earlier versions
// try AVAudioSession.sharedInstance().setCategory("AVAudioSessionCategoryAmbient")
}
//

// Find the sound file.
guard let soundFileURL = Bundle.main.url(forResource: name, withExtension: "") else {
assert(false, "File not exist")
Expand Down
18 changes: 9 additions & 9 deletions Sources/UIKit/UIImage+TSOrientation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,38 +25,38 @@ public extension UIImage {
*/
class func ts_fixImageOrientation(_ src:UIImage) -> UIImage {

if src.imageOrientation == UIImageOrientation.up {
if src.imageOrientation == UIImage.Orientation.up {
return src
}

var transform: CGAffineTransform = CGAffineTransform.identity

switch src.imageOrientation {
case UIImageOrientation.down, UIImageOrientation.downMirrored:
case UIImage.Orientation.down, UIImage.Orientation.downMirrored:
transform = transform.translatedBy(x: src.size.width, y: src.size.height)
transform = transform.rotated(by: CGFloat(Double.pi))
break
case UIImageOrientation.left, UIImageOrientation.leftMirrored:
case UIImage.Orientation.left, UIImage.Orientation.leftMirrored:
transform = transform.translatedBy(x: src.size.width, y: 0)
transform = transform.rotated(by: CGFloat(Double.pi))
break
case UIImageOrientation.right, UIImageOrientation.rightMirrored:
case UIImage.Orientation.right, UIImage.Orientation.rightMirrored:
transform = transform.translatedBy(x: 0, y: src.size.height)
transform = transform.rotated(by: CGFloat(-Double.pi))
break
case UIImageOrientation.up, UIImageOrientation.upMirrored:
case UIImage.Orientation.up, UIImage.Orientation.upMirrored:
break
}

switch src.imageOrientation {
case UIImageOrientation.upMirrored, UIImageOrientation.downMirrored:
case UIImage.Orientation.upMirrored, UIImage.Orientation.downMirrored:
transform.translatedBy(x: src.size.width, y: 0)
transform.scaledBy(x: -1, y: 1)
break
case UIImageOrientation.leftMirrored, UIImageOrientation.rightMirrored:
case UIImage.Orientation.leftMirrored, UIImage.Orientation.rightMirrored:
transform.translatedBy(x: src.size.height, y: 0)
transform.scaledBy(x: -1, y: 1)
case UIImageOrientation.up, UIImageOrientation.down, UIImageOrientation.left, UIImageOrientation.right:
case UIImage.Orientation.up, UIImage.Orientation.down, UIImage.Orientation.left, UIImage.Orientation.right:
break
}

Expand All @@ -65,7 +65,7 @@ public extension UIImage {
ctx.concatenate(transform)

switch src.imageOrientation {
case UIImageOrientation.left, UIImageOrientation.leftMirrored, UIImageOrientation.right, UIImageOrientation.rightMirrored:
case UIImage.Orientation.left, UIImage.Orientation.leftMirrored, UIImage.Orientation.right, UIImage.Orientation.rightMirrored:
ctx.draw(src.cgImage!, in: CGRect(x: 0, y: 0, width: src.size.height, height: src.size.width))
break
default:
Expand Down
4 changes: 2 additions & 2 deletions Sources/UIKit/UILabel+TSExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public extension UILabel {
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineBreakMode = self.lineBreakMode
paragraphStyle.alignment = self.textAlignment
let attributes: [NSAttributedStringKey : AnyObject] = [
let attributes: [NSAttributedString.Key : AnyObject] = [
.font: self.font,
.paragraphStyle: paragraphStyle]
let contentSize: CGSize = self.text!.boundingRect(
Expand All @@ -40,7 +40,7 @@ public extension UILabel {
*/
func ts_setFrameWithString(_ string: String, width: CGFloat) {
self.numberOfLines = 0
let attributes: [NSAttributedStringKey : AnyObject] = [
let attributes: [NSAttributedString.Key : AnyObject] = [
.font: self.font,
]
let resultSize: CGSize = string.boundingRect(
Expand Down
4 changes: 2 additions & 2 deletions Sources/UIKit/UINavigationController+TSExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extension UINavigationController {
- parameter controller: target viewController
- parameter transition: UIViewAnimationTransition
*/
public func ts_pushViewController(_ controller: UIViewController, transition: UIViewAnimationTransition) {
public func ts_pushViewController(_ controller: UIViewController, transition: UIView.AnimationTransition) {
UIView.beginAnimations(nil, context: nil)
self.pushViewController(controller, animated: false)
UIView.setAnimationDuration(0.5)
Expand All @@ -33,7 +33,7 @@ extension UINavigationController {

- returns: UIViewController
*/
public func ts_popViewController(_ controller: UIViewController, transition: UIViewAnimationTransition) -> UIViewController {
public func ts_popViewController(_ controller: UIViewController, transition: UIView.AnimationTransition) -> UIViewController {
UIView.beginAnimations(nil, context: nil)
let controller = self.popViewController(animated: false)
UIView.setAnimationDuration(0.5)
Expand Down
8 changes: 4 additions & 4 deletions Sources/UIKit/UINavigationItem+TSExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ public extension UINavigationItem {
- returns: Item button
*/
class func ts_itemButton(_ image: UIImage? = nil, text: String? = nil) -> UIButton {
let button: UIButton = UIButton(type: UIButtonType.custom)
let button: UIButton = UIButton(type: UIButton.ButtonType.custom)
if let aImage = image {
button.setImage(aImage, for: UIControlState())
button.setImage(aImage, for: UIControl.State())
}

var buttonWidth: CGFloat = 40
if let aText = text {
button.titleLabel?.font = UIFont.systemFont(ofSize: 16)
let attributes: [NSAttributedStringKey : AnyObject] = [
let attributes: [NSAttributedString.Key : AnyObject] = [
.font: button.titleLabel!.font,
]
let size: CGSize = aText.boundingRect(
Expand All @@ -78,7 +78,7 @@ public extension UINavigationItem {
).size

buttonWidth = size.width
button.setTitle(aText, for: UIControlState())
button.setTitle(aText, for: UIControl.State())
}
button.imageView!.contentMode = .scaleAspectFit;
button.frame = CGRect(x: 0, y: 0, width: buttonWidth, height: 30)
Expand Down
6 changes: 4 additions & 2 deletions Sources/UIKit/UIScreen+TSExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public extension UIScreen {
return CGSize.zero
}
let systemVersion = (UIDevice.current.systemVersion as NSString).floatValue
let isLand: Bool = UIInterfaceOrientationIsLandscape(app.statusBarOrientation)
let isLand: Bool = UIInterfaceOrientation.landscapeLeft == app.statusBarOrientation || UIInterfaceOrientation.landscapeRight == app.statusBarOrientation
// UIInterfaceOrientationIsLandscape(app.statusBarOrientation)
return (systemVersion > 8.0 && isLand) ? UIScreen.ts_swapSize(self.ts_size) : self.ts_size
}

Expand Down Expand Up @@ -71,7 +72,8 @@ public extension UIScreen {
guard let app = UIApplication.ts_sharedApplication() else {
return 0
}
if UIInterfaceOrientationIsPortrait(app.statusBarOrientation) {

if UIInterfaceOrientation.portrait == app.statusBarOrientation {
return UIScreen.main.bounds.size.height - app.statusBarFrame.height
} else {
return UIScreen.main.bounds.size.width - app.statusBarFrame.height
Expand Down
4 changes: 2 additions & 2 deletions Sources/UIKit/UIViewController+TSExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public extension UIViewController {
return
}

let button: UIButton = UIButton(type: UIButtonType.custom)
button.setImage(backImage, for: UIControlState())
let button: UIButton = UIButton(type: UIButton.ButtonType.custom)
button.setImage(backImage, for: UIControl.State())
button.frame = CGRect(x: 0, y: 0, width: 40, height: 30)
button.imageView!.contentMode = .scaleAspectFit;
button.contentHorizontalAlignment = .left
Expand Down