Skip to content

Commit 58c3fe6

Browse files
authored
Merge pull request MengTo#180 from RishabhTayal/swift3
Updated to Xcode 8 beta 4
2 parents 4a7bcbd + b6d03de commit 58c3fe6

20 files changed

+80
-78
lines changed

Spring/AutoTextView.swift

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,19 @@
99
import UIKit
1010

1111
public class AutoTextView: UITextView {
12-
override public func intrinsicContentSize() -> CGSize {
13-
var size = self.sizeThatFits(CGSize(width: self.frame.size.width, height: CGFloat.greatestFiniteMagnitude))
14-
size.width = self.frame.size.width
15-
if text.length == 0 {
16-
size.height = 0
12+
13+
public override var intrinsicContentSize: CGSize {
14+
get {
15+
var size = self.sizeThatFits(CGSize(width: self.frame.size.width, height: CGFloat.greatestFiniteMagnitude))
16+
size.width = self.frame.size.width
17+
if text.length == 0 {
18+
size.height = 0
19+
}
20+
21+
contentInset = UIEdgeInsetsMake(-4, -4, -4, -4)
22+
layoutIfNeeded()
23+
24+
return size
1725
}
18-
19-
contentInset = UIEdgeInsetsMake(-4, -4, -4, -4)
20-
layoutIfNeeded()
21-
22-
return size
2326
}
2427
}

Spring/BlurView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import UIKit
2424

2525
public func insertBlurView (view: UIView, style: UIBlurEffectStyle) -> UIVisualEffectView {
26-
view.backgroundColor = UIColor.clear()
26+
view.backgroundColor = UIColor.clear
2727

2828
let blurEffect = UIBlurEffect(style: style)
2929
let blurEffectView = UIVisualEffectView(effect: blurEffect)

Spring/DesignableButton.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import UIKit
2424

2525
@IBDesignable public class DesignableButton: SpringButton {
2626

27-
@IBInspectable public var borderColor: UIColor = UIColor.clear() {
27+
@IBInspectable public var borderColor: UIColor = UIColor.clear {
2828
didSet {
2929
layer.borderColor = borderColor.cgColor
3030
}
@@ -42,7 +42,7 @@ import UIKit
4242
}
4343
}
4444

45-
@IBInspectable public var shadowColor: UIColor = UIColor.clear() {
45+
@IBInspectable public var shadowColor: UIColor = UIColor.clear {
4646
didSet {
4747
layer.shadowColor = shadowColor.cgColor
4848
}

Spring/DesignableImageView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import UIKit
2424

2525
@IBDesignable public class DesignableImageView: SpringImageView {
2626

27-
@IBInspectable public var borderColor: UIColor = UIColor.clear() {
27+
@IBInspectable public var borderColor: UIColor = UIColor.clear {
2828
didSet {
2929
layer.borderColor = borderColor.cgColor
3030
}

Spring/DesignableTabBarController.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ import UIKit
2424

2525
@IBDesignable class DesignableTabBarController: UITabBarController {
2626

27-
@IBInspectable var normalTint: UIColor = UIColor.clear() {
27+
@IBInspectable var normalTint: UIColor = UIColor.clear {
2828
didSet {
2929
UITabBar.appearance().tintColor = normalTint
3030
UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: normalTint], for: UIControlState())
3131
}
3232
}
3333

34-
@IBInspectable var selectedTint: UIColor = UIColor.clear() {
34+
@IBInspectable var selectedTint: UIColor = UIColor.clear {
3535
didSet {
3636
UITabBar.appearance().tintColor = selectedTint
3737
UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: selectedTint], for:UIControlState.selected)
@@ -105,12 +105,12 @@ extension UIImage {
105105
UIGraphicsBeginImageContextWithOptions(self.size, false, self.scale)
106106

107107
let context = UIGraphicsGetCurrentContext()
108-
context!.translate(x: 0, y: self.size.height)
109-
context!.scale(x: 1.0, y: -1.0);
108+
context!.translateBy(x: 0, y: self.size.height)
109+
context!.scaleBy(x: 1.0, y: -1.0);
110110
context!.setBlendMode(CGBlendMode.normal)
111111

112112
let rect = CGRect(x: 0, y: 0, width: self.size.width, height: self.size.height)
113-
context!.clipToMask(rect, mask: self.cgImage!)
113+
context?.clip(to: rect, mask: self.cgImage!)
114114
tintColor.setFill()
115115
context!.fill(rect)
116116

Spring/DesignableTextField.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ import UIKit
2424

2525
@IBDesignable public class DesignableTextField: SpringTextField {
2626

27-
@IBInspectable public var placeholderColor: UIColor = UIColor.clear() {
27+
@IBInspectable public var placeholderColor: UIColor = UIColor.clear {
2828
didSet {
29-
attributedPlaceholder = AttributedString(string: placeholder!, attributes: [NSForegroundColorAttributeName: placeholderColor])
29+
attributedPlaceholder = NSAttributedString(string: placeholder!, attributes: [NSForegroundColorAttributeName: placeholderColor])
3030
layoutSubviews()
3131

3232
}
@@ -62,7 +62,7 @@ import UIKit
6262
}
6363
}
6464

65-
@IBInspectable public var borderColor: UIColor = UIColor.clear() {
65+
@IBInspectable public var borderColor: UIColor = UIColor.clear {
6666
didSet {
6767
layer.borderColor = borderColor.cgColor
6868
}

Spring/DesignableTextView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import UIKit
2424

2525
@IBDesignable public class DesignableTextView: SpringTextView {
2626

27-
@IBInspectable public var borderColor: UIColor = UIColor.clear() {
27+
@IBInspectable public var borderColor: UIColor = UIColor.clear {
2828
didSet {
2929
layer.borderColor = borderColor.cgColor
3030
}

Spring/DesignableView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import UIKit
2424

2525
@IBDesignable public class DesignableView: SpringView {
2626

27-
@IBInspectable public var borderColor: UIColor = UIColor.clear() {
27+
@IBInspectable public var borderColor: UIColor = UIColor.clear {
2828
didSet {
2929
layer.borderColor = borderColor.cgColor
3030
}
@@ -42,7 +42,7 @@ import UIKit
4242
}
4343
}
4444

45-
@IBInspectable public var shadowColor: UIColor = UIColor.clear() {
45+
@IBInspectable public var shadowColor: UIColor = UIColor.clear {
4646
didSet {
4747
layer.shadowColor = shadowColor.cgColor
4848
}

Spring/ImageLoader.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import Foundation
2626

2727
public class ImageLoader {
2828

29-
var cache = Cache<NSString, NSData>()
29+
var cache = NSCache<NSString, NSData>()
3030

3131
public class var sharedLoader : ImageLoader {
3232
struct Static {
@@ -36,7 +36,7 @@ public class ImageLoader {
3636
}
3737

3838
public func imageForUrl(urlString: String, completionHandler:(image: UIImage?, url: String) -> ()) {
39-
DispatchQueue.global(attributes: DispatchQueue.GlobalAttributes.qosBackground).async(execute: {()in
39+
DispatchQueue.global(qos: DispatchQoS.QoSClass.background).async {
4040
let data: NSData? = self.cache.object(forKey: urlString)! as NSData
4141

4242
if let goodData = data {
@@ -47,7 +47,7 @@ public class ImageLoader {
4747
return
4848
}
4949

50-
let downloadTask: URLSessionDataTask = URLSession.shared().dataTask(with: URL(string: urlString)!, completionHandler: { (data, response, error) -> Void in
50+
let downloadTask: URLSessionDataTask = URLSession.shared.dataTask(with: URL(string: urlString)!, completionHandler: { (data, response, error) -> Void in
5151

5252
if (error != nil) {
5353
completionHandler(image: nil, url: urlString)
@@ -65,7 +65,7 @@ public class ImageLoader {
6565
})
6666
downloadTask.resume()
6767

68-
})
68+
}
6969

7070
}
7171
}

Spring/KeyboardLayoutConstraint.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,20 @@ public class KeyboardLayoutConstraint: NSLayoutConstraint {
3232

3333
offset = constant
3434

35-
NotificationCenter.default().addObserver(self, selector: #selector(KeyboardLayoutConstraint.keyboardWillShowNotification(_:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
36-
NotificationCenter.default().addObserver(self, selector: #selector(KeyboardLayoutConstraint.keyboardWillHideNotification(_:)), name: NSNotification.Name.UIKeyboardWillHide, object: nil)
35+
NotificationCenter.default.addObserver(self, selector: #selector(KeyboardLayoutConstraint.keyboardWillShowNotification(_:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
36+
NotificationCenter.default.addObserver(self, selector: #selector(KeyboardLayoutConstraint.keyboardWillHideNotification(_:)), name: NSNotification.Name.UIKeyboardWillHide, object: nil)
3737
}
3838

3939
deinit {
40-
NotificationCenter.default().removeObserver(self)
40+
NotificationCenter.default.removeObserver(self)
4141
}
4242

4343
// MARK: Notification
4444

4545
func keyboardWillShowNotification(_ notification: Notification) {
4646
if let userInfo = notification.userInfo {
4747
if let frameValue = userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue {
48-
let frame = frameValue.cgRectValue()
48+
let frame = frameValue.cgRectValue
4949
keyboardVisibleHeight = frame.size.height
5050
}
5151

@@ -60,7 +60,7 @@ public class KeyboardLayoutConstraint: NSLayoutConstraint {
6060
delay: 0,
6161
options: options,
6262
animations: {
63-
UIApplication.shared().keyWindow?.layoutIfNeeded()
63+
UIApplication.shared.keyWindow?.layoutIfNeeded()
6464
return
6565
}, completion: { finished in
6666
})
@@ -89,7 +89,7 @@ public class KeyboardLayoutConstraint: NSLayoutConstraint {
8989
delay: 0,
9090
options: options,
9191
animations: {
92-
UIApplication.shared().keyWindow?.layoutIfNeeded()
92+
UIApplication.shared.keyWindow?.layoutIfNeeded()
9393
return
9494
}, completion: { finished in
9595
})

0 commit comments

Comments
 (0)