Commit 4f2d6628 by Daniel Dahan

issue-44: updated to iOS 9

parent a45f4e2e
......@@ -324,6 +324,8 @@
9638322D1B88DFD80015F710 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftMigration = 0710;
LastSwiftUpdateCheck = 0710;
LastUpgradeCheck = 0640;
ORGANIZATIONNAME = "GraphKit, Inc.";
TargetAttributes = {
......
......@@ -230,14 +230,14 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
// container
if nil == titleLabelContainer {
titleLabelContainer = UIView()
titleLabelContainer!.setTranslatesAutoresizingMaskIntoConstraints(false)
titleLabelContainer!.translatesAutoresizingMaskIntoConstraints = false
titleLabelContainer!.backgroundColor = MaterialTheme.clear.color
addSubview(titleLabelContainer!)
}
// text
titleLabelContainer!.addSubview(t)
t.setTranslatesAutoresizingMaskIntoConstraints(false)
t.translatesAutoresizingMaskIntoConstraints = false
t.backgroundColor = MaterialTheme.clear.color
t.font = Roboto.regular
t.numberOfLines = 0
......@@ -273,14 +273,14 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
// container
if nil == detailLabelContainer {
detailLabelContainer = UIView()
detailLabelContainer!.setTranslatesAutoresizingMaskIntoConstraints(false)
detailLabelContainer!.translatesAutoresizingMaskIntoConstraints = false
detailLabelContainer!.backgroundColor = MaterialTheme.clear.color
addSubview(detailLabelContainer!)
}
// text
detailLabelContainer!.addSubview(l)
l.setTranslatesAutoresizingMaskIntoConstraints(false)
l.translatesAutoresizingMaskIntoConstraints = false
l.textColor = MaterialTheme.white.color
l.backgroundColor = MaterialTheme.clear.color
l.font = Roboto.light
......@@ -299,7 +299,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
public var divider: UIView? {
didSet {
if let d = divider {
d.setTranslatesAutoresizingMaskIntoConstraints(false)
d.translatesAutoresizingMaskIntoConstraints = false
d.backgroundColor = MaterialTheme.blueGrey.darken1
addSubview(d)
} else {
......@@ -322,7 +322,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
if let b = leftButtons {
if nil == buttonsContainer {
buttonsContainer = UIView()
buttonsContainer!.setTranslatesAutoresizingMaskIntoConstraints(false)
buttonsContainer!.translatesAutoresizingMaskIntoConstraints = false
buttonsContainer!.backgroundColor = MaterialTheme.clear.color
addSubview(buttonsContainer!)
}
......@@ -341,7 +341,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
if let b = rightButtons {
if nil == buttonsContainer {
buttonsContainer = UIView()
buttonsContainer!.setTranslatesAutoresizingMaskIntoConstraints(false)
buttonsContainer!.translatesAutoresizingMaskIntoConstraints = false
buttonsContainer!.backgroundColor = MaterialTheme.clear.color
addSubview(buttonsContainer!)
}
......@@ -355,7 +355,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
/**
:name: init
*/
public required init(coder aDecoder: NSCoder) {
public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
......@@ -409,10 +409,10 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
// title
if nil != titleLabelContainer && nil != titleLabel {
// clear for updated constraints
titleLabelContainer!.removeConstraints(titleLabelContainer!.constraints())
titleLabelContainer!.removeConstraints(titleLabelContainer!.constraints)
// container
layoutConstraints += Layout.constraint("H:|[titleLabelContainer]|", options: nil, metrics: nil, views: ["titleLabelContainer": titleLabelContainer!])
layoutConstraints += Layout.constraint("H:|[titleLabelContainer]|", options: [], metrics: nil, views: ["titleLabelContainer": titleLabelContainer!])
verticalFormat += "[titleLabelContainer]"
views["titleLabelContainer"] = titleLabelContainer!
......@@ -421,17 +421,17 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
Layout.expandToParentWithPad(titleLabelContainer!, child: titleLabel!, top: titleLabelTopInset, left: titleLabelLeftInset, bottom: titleLabelBottomInset, right: titleLabelRightInset)
} else {
Layout.expandToParentHorizontallyWithPad(titleLabelContainer!, child: titleLabel!, left: titleLabelLeftInset, right: titleLabelRightInset)
titleLabelContainer!.addConstraints(Layout.constraint("V:|-(titleLabelTopInset)-[titleLabel(<=maximumTitleLabelHeight)]-(titleLabelBottomInset)-|", options: nil, metrics: ["titleLabelTopInset": titleLabelTopInset, "titleLabelBottomInset": titleLabelBottomInset, "maximumTitleLabelHeight": maximumTitleLabelHeight], views: ["titleLabel": titleLabel!]))
titleLabelContainer!.addConstraints(Layout.constraint("V:|-(titleLabelTopInset)-[titleLabel(<=maximumTitleLabelHeight)]-(titleLabelBottomInset)-|", options: [], metrics: ["titleLabelTopInset": titleLabelTopInset, "titleLabelBottomInset": titleLabelBottomInset, "maximumTitleLabelHeight": maximumTitleLabelHeight], views: ["titleLabel": titleLabel!]))
}
}
// detail
if nil != detailLabelContainer && nil != detailLabel {
// clear for updated constraints
detailLabelContainer!.removeConstraints(detailLabelContainer!.constraints())
detailLabelContainer!.removeConstraints(detailLabelContainer!.constraints)
// container
layoutConstraints += Layout.constraint("H:|[detailLabelContainer]|", options: nil, metrics: nil, views: ["detailLabelContainer": detailLabelContainer!])
layoutConstraints += Layout.constraint("H:|[detailLabelContainer]|", options: [], metrics: nil, views: ["detailLabelContainer": detailLabelContainer!])
verticalFormat += "[detailLabelContainer]"
views["detailLabelContainer"] = detailLabelContainer!
......@@ -439,24 +439,24 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
Layout.expandToParentWithPad(detailLabelContainer!, child: detailLabel!, top: detailLabelTopInset, left: detailLabelLeftInset, bottom: detailLabelBottomInset, right: detailLabelRightInset)
} else {
Layout.expandToParentHorizontallyWithPad(detailLabelContainer!, child: detailLabel!, left: detailLabelLeftInset, right: detailLabelRightInset)
detailLabelContainer!.addConstraints(Layout.constraint("V:|-(detailLabelTopInset)-[detailLabel(<=maximumDetailLabelHeight)]-(detailLabelBottomInset)-|", options: nil, metrics: ["detailLabelTopInset": detailLabelTopInset, "detailLabelBottomInset": detailLabelBottomInset, "maximumDetailLabelHeight": maximumDetailLabelHeight], views: ["detailLabel": detailLabel!]))
detailLabelContainer!.addConstraints(Layout.constraint("V:|-(detailLabelTopInset)-[detailLabel(<=maximumDetailLabelHeight)]-(detailLabelBottomInset)-|", options: [], metrics: ["detailLabelTopInset": detailLabelTopInset, "detailLabelBottomInset": detailLabelBottomInset, "maximumDetailLabelHeight": maximumDetailLabelHeight], views: ["detailLabel": detailLabel!]))
}
}
// buttons
if nil != buttonsContainer && (nil != leftButtons || nil != rightButtons) {
// clear for updated constraints
buttonsContainer!.removeConstraints(buttonsContainer!.constraints())
buttonsContainer!.removeConstraints(buttonsContainer!.constraints)
// divider
if nil != divider {
layoutConstraints += Layout.constraint("H:|[divider]|", options: nil, metrics: nil, views: ["divider": divider!])
layoutConstraints += Layout.constraint("H:|[divider]|", options: [], metrics: nil, views: ["divider": divider!])
views["divider"] = divider!
verticalFormat += "[divider(1)]"
}
//container
layoutConstraints += Layout.constraint("H:|[buttonsContainer]|", options: nil, metrics: nil, views: ["buttonsContainer": buttonsContainer!])
layoutConstraints += Layout.constraint("H:|[buttonsContainer]|", options: [], metrics: nil, views: ["buttonsContainer": buttonsContainer!])
verticalFormat += "[buttonsContainer]"
views["buttonsContainer"] = buttonsContainer!
......@@ -471,7 +471,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
horizontalFormat += "-(buttonLeftInset)-[button\(i)]"
Layout.expandToParentVerticallyWithPad(buttonsContainer!, child: button, top: buttonTopInset, bottom: buttonBottomInset)
}
buttonsContainer!.addConstraints(Layout.constraint(horizontalFormat, options: nil, metrics: ["buttonLeftInset": buttonLeftInset], views: buttonViews))
buttonsContainer!.addConstraints(Layout.constraint(horizontalFormat, options: [], metrics: ["buttonLeftInset": buttonLeftInset], views: buttonViews))
}
// rightButtons
......@@ -485,7 +485,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
horizontalFormat += "[button\(i)]-(buttonRightInset)-"
Layout.expandToParentVerticallyWithPad(buttonsContainer!, child: button, top: buttonTopInset, bottom: buttonBottomInset)
}
buttonsContainer!.addConstraints(Layout.constraint(horizontalFormat + "|", options: nil, metrics: ["buttonRightInset": buttonRightInset], views: buttonViews))
buttonsContainer!.addConstraints(Layout.constraint(horizontalFormat + "|", options: [], metrics: ["buttonRightInset": buttonRightInset], views: buttonViews))
}
}
......@@ -493,7 +493,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
// combine constraints
if 0 < layoutConstraints.count {
layoutConstraints += Layout.constraint(verticalFormat, options: nil, metrics: nil, views: views)
layoutConstraints += Layout.constraint(verticalFormat, options: [], metrics: nil, views: views)
NSLayoutConstraint.activateConstraints(layoutConstraints)
}
}
......
......@@ -101,7 +101,7 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
// setup default camera device
let videoDevice: AVCaptureDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo)
var videoInput: AVCaptureDeviceInput? = AVCaptureDeviceInput.deviceInputWithDevice(videoDevice, error: &error) as? AVCaptureDeviceInput
let videoInput: AVCaptureDeviceInput? = AVCaptureDeviceInput.deviceInputWithDevice(videoDevice) as? AVCaptureDeviceInput
if nil == videoInput {
return false
......@@ -113,7 +113,7 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
}
let audioDevice: AVCaptureDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeAudio)
var audioInput: AVCaptureDeviceInput? = AVCaptureDeviceInput.deviceInputWithDevice(audioDevice, error: &error) as? AVCaptureDeviceInput
let audioInput: AVCaptureDeviceInput? = AVCaptureDeviceInput.deviceInputWithDevice(audioDevice) as? AVCaptureDeviceInput
if nil == audioInput {
return false
......@@ -218,9 +218,9 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
return false
}
var error: NSError?
var videoDevice: AVCaptureDevice? = inactiveCamera
var videoInput: AVCaptureDeviceInput? = AVCaptureDeviceInput.deviceInputWithDevice(videoDevice, error: &error) as? AVCaptureDeviceInput
let error: NSError?
let videoDevice: AVCaptureDevice? = inactiveCamera
let videoInput: AVCaptureDeviceInput? = AVCaptureDeviceInput.deviceInputWithDevice(videoDevice) as? AVCaptureDeviceInput
if nil == videoInput {
session.beginConfiguration()
......@@ -263,10 +263,12 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
let device: AVCaptureDevice = activeCamera
if flashMode != device.flashMode && device.isFlashModeSupported(flashMode) {
var error: NSError?
if device.lockForConfiguration(&error) {
do {
try device.lockForConfiguration()
device.flashMode = flashMode
device.unlockForConfiguration()
} else {
} catch let error1 as NSError {
error = error1
delegate?.captureDeviceConfigurationFailed?(self, error: error)
}
}
......@@ -297,10 +299,12 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
let device: AVCaptureDevice = activeCamera
if torchMode != device.torchMode && device.isTorchModeSupported(torchMode) {
var error: NSError?
if device.lockForConfiguration(&error) {
do {
try device.lockForConfiguration()
device.torchMode = torchMode
device.unlockForConfiguration()
} else {
} catch let error1 as NSError {
error = error1
delegate?.captureDeviceConfigurationFailed?(self, error: error)
}
}
......@@ -328,11 +332,13 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
let device: AVCaptureDevice = activeCamera
if device.focusPointOfInterestSupported && device.isFocusModeSupported(.AutoFocus) {
var error: NSError?
if device.lockForConfiguration(&error) {
do {
try device.lockForConfiguration()
device.focusPointOfInterest = point
device.focusMode = .AutoFocus
device.unlockForConfiguration()
} else {
} catch let error1 as NSError {
error = error1
delegate?.captureDeviceConfigurationFailed?(self, error: error)
}
}
......@@ -356,11 +362,12 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
*/
public func exposeAtPoint(point: CGPoint) {
let device: AVCaptureDevice = activeCamera
var exposureMode: AVCaptureExposureMode = .ContinuousAutoExposure
let exposureMode: AVCaptureExposureMode = .ContinuousAutoExposure
if device.exposurePointOfInterestSupported && device.isExposureModeSupported(exposureMode) {
var error: NSError?
if device.lockForConfiguration(&error) {
do {
try device.lockForConfiguration()
device.exposurePointOfInterest = point
device.exposureMode = exposureMode
......@@ -368,7 +375,8 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
device.addObserver(self, forKeyPath: "adjustingExposure", options: .New, context: &CaptureAdjustingExposureContext)
}
device.unlockForConfiguration()
} else {
} catch let error1 as NSError {
error = error1
delegate?.captureDeviceConfigurationFailed?(self, error: error)
}
}
......@@ -378,7 +386,7 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
* override to set observeValueForKeyPath and handle exposure observance.
* @delegate If the configuration fails, the capture(capture: Capture!, deviceConfigurationFailed error: NSError!) is called.
*/
override public func observeValueForKeyPath(keyPath: String, ofObject object: AnyObject, change: [NSObject : AnyObject], context: UnsafeMutablePointer<Void>) {
override public func observeValueForKeyPath(keyPath: String?, ofObject object: AnyObject?, change: [String : AnyObject]?, context: UnsafeMutablePointer<Void>) {
if context == &CaptureAdjustingExposureContext {
let device: AVCaptureDevice = object as! AVCaptureDevice
......@@ -386,10 +394,14 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
object.removeObserver(self, forKeyPath: "adjustingExposure", context: &CaptureAdjustingExposureContext)
dispatch_async(queue) {
var error: NSError?
if device.lockForConfiguration(&error) {
do {
try device.lockForConfiguration()
device.unlockForConfiguration()
} else {
} catch var error1 as NSError {
error = error1
self.delegate?.captureDeviceConfigurationFailed?(self, error: error)
} catch {
fatalError()
}
}
} else {
......@@ -406,16 +418,17 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
public func resetFocusAndExposureModes() {
let device: AVCaptureDevice = activeCamera
var exposureMode: AVCaptureExposureMode = .ContinuousAutoExposure
let exposureMode: AVCaptureExposureMode = .ContinuousAutoExposure
let canResetExposure: Bool = device.focusPointOfInterestSupported && device.isExposureModeSupported(exposureMode)
var focusMode: AVCaptureFocusMode = .ContinuousAutoFocus
let focusMode: AVCaptureFocusMode = .ContinuousAutoFocus
let canResetFocus: Bool = device.focusPointOfInterestSupported && device.isFocusModeSupported(focusMode)
let centerPoint: CGPoint = CGPointMake(0.5, 0.5)
var error: NSError?
if device.lockForConfiguration(&error) {
do {
try device.lockForConfiguration()
if canResetFocus {
device.focusMode = focusMode
device.focusPointOfInterest = centerPoint
......@@ -425,7 +438,8 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
device.exposurePointOfInterest = centerPoint
}
device.unlockForConfiguration()
} else {
} catch let error1 as NSError {
error = error1
delegate?.captureDeviceConfigurationFailed?(self, error: error)
}
}
......@@ -437,7 +451,7 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
* @delegate If failure, capture(capture: Capture!, assetLibraryWriteFailed error: NSError!) is called.
*/
public func captureStillImage() {
var connection: AVCaptureConnection = imageOutput.connectionWithMediaType(AVMediaTypeVideo)
let connection: AVCaptureConnection = imageOutput.connectionWithMediaType(AVMediaTypeVideo)
if connection.supportsVideoOrientation {
connection.videoOrientation = currentVideoOrientation
}
......@@ -482,10 +496,12 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
if device.smoothAutoFocusSupported {
var error: NSError?
if device.lockForConfiguration(&error) {
do {
try device.lockForConfiguration()
device.smoothAutoFocusEnabled = false
device.unlockForConfiguration()
} else {
} catch let error1 as NSError {
error = error1
delegate?.captureDeviceConfigurationFailed?(self, error: error)
}
}
......@@ -546,9 +562,12 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
private var uniqueURL: NSURL? {
var error: NSError?
let fileManager: NSFileManager = NSFileManager.defaultManager()
let tempDirectoryTemplate: String = NSTemporaryDirectory().stringByAppendingPathComponent("FocusLibrary")
if fileManager.createDirectoryAtPath(tempDirectoryTemplate, withIntermediateDirectories: true, attributes: nil, error: &error) {
let tempDirectoryTemplate: String = (NSTemporaryDirectory() as NSString).stringByAppendingPathComponent("FocusLibrary")
do {
try fileManager.createDirectoryAtPath(tempDirectoryTemplate, withIntermediateDirectories: true, attributes: nil)
return NSURL.fileURLWithPath(tempDirectoryTemplate + "/test.mov")
} catch let error1 as NSError {
error = error1
}
return nil
}
......@@ -611,13 +630,13 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
*/
private func generateThumbnailForVideoAtURL(videoURL: NSURL!) {
dispatch_async(queue) {
let asset: AVAsset = AVAsset.assetWithURL(videoURL) as! AVAsset
let asset: AVAsset = AVAsset.assetWithURL(videoURL)
let imageGenerator: AVAssetImageGenerator = AVAssetImageGenerator(asset: asset)
imageGenerator.maximumSize = CGSizeMake(100, 0)
imageGenerator.appliesPreferredTrackTransform = true
let imageRef: CGImageRef = imageGenerator.copyCGImageAtTime(kCMTimeZero, actualTime: nil, error: nil)
let image: UIImage = UIImage(CGImage: imageRef)!
let imageRef: CGImageRef = try? imageGenerator.copyCGImageAtTime(kCMTimeZero, actualTime: nil)
let image: UIImage = UIImage(CGImage: imageRef)
dispatch_async(dispatch_get_main_queue()) {
self.postAssetLibraryNotification(image)
......
......@@ -118,7 +118,7 @@ public class Preview: UIView {
//
private var doubleDoubleTapRecognizer: UITapGestureRecognizer?
required public init(coder aDecoder: NSCoder) {
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
prepareView()
}
......@@ -130,7 +130,7 @@ public class Preview: UIView {
public init() {
super.init(frame: CGRectZero)
setTranslatesAutoresizingMaskIntoConstraints(false)
translatesAutoresizingMaskIntoConstraints = false
prepareView()
}
......
......@@ -25,7 +25,7 @@ public struct Layout {
public static func width(parent: UIView, child: UIView, width: CGFloat = 0) {
let metrics: Dictionary<String, AnyObject> = ["width" : width]
let views: Dictionary<String, AnyObject> = ["child" : child]
parent.addConstraints(constraint("H:[child(width)]", options: nil, metrics: metrics, views: views))
parent.addConstraints(constraint("H:[child(width)]", options: [], metrics: metrics, views: views))
}
/**
......@@ -34,7 +34,7 @@ public struct Layout {
public static func height(parent: UIView, child: UIView, height: CGFloat = 0) {
let metrics: Dictionary<String, AnyObject> = ["height" : height]
let views: Dictionary<String, AnyObject> = ["child" : child]
parent.addConstraints(constraint("V:[child(height)]", options: nil, metrics: metrics, views: views))
parent.addConstraints(constraint("V:[child(height)]", options: [], metrics: metrics, views: views))
}
/**
......@@ -50,8 +50,8 @@ public struct Layout {
*/
public static func expandToParent(parent: UIView, child: UIView) {
let views: Dictionary<String, AnyObject> = ["child" : child]
parent.addConstraints(constraint("H:|[child]|", options: nil, metrics: nil, views: views))
parent.addConstraints(constraint("V:|[child]|", options: nil, metrics: nil, views: views))
parent.addConstraints(constraint("H:|[child]|", options: [], metrics: nil, views: views))
parent.addConstraints(constraint("V:|[child]|", options: [], metrics: nil, views: views))
}
/**
......@@ -65,7 +65,7 @@ public struct Layout {
:name: expandToParentHorizontallyWithPad
*/
public static func expandToParentHorizontallyWithPad(parent: UIView, child: UIView, left: CGFloat = 0, right: CGFloat = 0) {
parent.addConstraints(constraint("H:|-(left)-[child]-(right)-|", options: nil, metrics: ["left": left, "right": right], views: ["child" : child]))
parent.addConstraints(constraint("H:|-(left)-[child]-(right)-|", options: [], metrics: ["left": left, "right": right], views: ["child" : child]))
}
/**
......@@ -79,7 +79,7 @@ public struct Layout {
:name: expandToParentVerticallyWithPad
*/
public static func expandToParentVerticallyWithPad(parent: UIView, child: UIView, top: CGFloat = 0, bottom: CGFloat = 0) {
parent.addConstraints(constraint("V:|-(top)-[child]-(bottom)-|", options: nil, metrics: ["bottom": bottom, "top": top], views: ["child" : child]))
parent.addConstraints(constraint("V:|-(top)-[child]-(bottom)-|", options: [], metrics: ["bottom": bottom, "top": top], views: ["child" : child]))
}
/**
......@@ -87,8 +87,8 @@ public struct Layout {
*/
public static func expandToParentWithPad(parent: UIView, child: UIView, top: CGFloat = 0, left: CGFloat = 0, bottom: CGFloat = 0, right: CGFloat = 0) {
let views: Dictionary<String, AnyObject> = ["child" : child]
parent.addConstraints(constraint("H:|-(left)-[child]-(right)-|", options: nil, metrics: ["left": left, "right": right], views: views))
parent.addConstraints(constraint("V:|-(top)-[child]-(bottom)-|", options: nil, metrics: ["bottom": bottom, "top": top], views: views))
parent.addConstraints(constraint("H:|-(left)-[child]-(right)-|", options: [], metrics: ["left": left, "right": right], views: views))
parent.addConstraints(constraint("V:|-(top)-[child]-(bottom)-|", options: [], metrics: ["bottom": bottom, "top": top], views: views))
}
/**
......@@ -97,8 +97,8 @@ public struct Layout {
public static func alignFromTopLeft(parent: UIView, child: UIView, top: CGFloat = 0, left: CGFloat = 0) {
let metrics: Dictionary<String, AnyObject> = ["top" : top, "left" : left]
let views: Dictionary<String, AnyObject> = ["child" : child]
parent.addConstraints(constraint("H:|-(left)-[child]", options: nil, metrics: metrics, views: views))
parent.addConstraints(constraint("V:|-(top)-[child]", options: nil, metrics: metrics, views: views))
parent.addConstraints(constraint("H:|-(left)-[child]", options: [], metrics: metrics, views: views))
parent.addConstraints(constraint("V:|-(top)-[child]", options: [], metrics: metrics, views: views))
}
/**
......@@ -107,8 +107,8 @@ public struct Layout {
public static func alignFromTopRight(parent: UIView, child: UIView, top: CGFloat = 0, right: CGFloat = 0) {
let metrics: Dictionary<String, AnyObject> = ["top" : top, "right" : right]
let views: Dictionary<String, AnyObject> = ["child" : child]
parent.addConstraints(constraint("H:[child]-(right)-|", options: nil, metrics: metrics, views: views))
parent.addConstraints(constraint("V:|-(top)-[child]", options: nil, metrics: metrics, views: views))
parent.addConstraints(constraint("H:[child]-(right)-|", options: [], metrics: metrics, views: views))
parent.addConstraints(constraint("V:|-(top)-[child]", options: [], metrics: metrics, views: views))
}
/**
......@@ -117,8 +117,8 @@ public struct Layout {
public static func alignFromBottomLeft(parent: UIView, child: UIView, bottom: CGFloat = 0, left: CGFloat = 0) {
let metrics: Dictionary<String, AnyObject> = ["bottom" : bottom, "left" : left]
let views: Dictionary<String, AnyObject> = ["child" : child]
parent.addConstraints(constraint("H:|-(left)-[child]", options: nil, metrics: metrics, views: views))
parent.addConstraints(constraint("V:[child]-(bottom)-|", options: nil, metrics: metrics, views: views))
parent.addConstraints(constraint("H:|-(left)-[child]", options: [], metrics: metrics, views: views))
parent.addConstraints(constraint("V:[child]-(bottom)-|", options: [], metrics: metrics, views: views))
}
/**
......@@ -127,8 +127,8 @@ public struct Layout {
public static func alignFromBottomRight(parent: UIView, child: UIView, bottom: CGFloat = 0, right: CGFloat = 0) {
let metrics: Dictionary<String, AnyObject> = ["bottom" : bottom, "right" : right]
let views: Dictionary<String, AnyObject> = ["child" : child]
parent.addConstraints(constraint("H:[child]-(right)-|", options: nil, metrics: metrics, views: views))
parent.addConstraints(constraint("V:[child]-(bottom)-|", options: nil, metrics: metrics, views: views))
parent.addConstraints(constraint("H:[child]-(right)-|", options: [], metrics: metrics, views: views))
parent.addConstraints(constraint("V:[child]-(bottom)-|", options: [], metrics: metrics, views: views))
}
/**
......@@ -150,6 +150,6 @@ public struct Layout {
options: options,
metrics: metrics,
views: views
) as! Array<NSLayoutConstraint>
)
}
}
......@@ -49,7 +49,7 @@ public class MaterialButton : UIButton {
/**
:name: init
*/
public required init(coder aDecoder: NSCoder) {
public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
prepareView()
}
......@@ -72,7 +72,7 @@ public class MaterialButton : UIButton {
/**
:name: touchesBegan
*/
public override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
public override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesBegan(touches, withEvent: event)
pulseBegan(touches, withEvent: event)
}
......@@ -80,7 +80,7 @@ public class MaterialButton : UIButton {
/**
:name: touchesEnded
*/
public override func touchesEnded(touches: Set<NSObject>, withEvent event: UIEvent) {
public override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesEnded(touches, withEvent: event)
shrink()
pulseEnded(touches, withEvent: event)
......@@ -89,7 +89,7 @@ public class MaterialButton : UIButton {
/**
:name: touchesCancelled
*/
public override func touchesCancelled(touches: Set<NSObject>!, withEvent event: UIEvent!) {
public override func touchesCancelled(touches: Set<UITouch>?, withEvent event: UIEvent?) {
super.touchesCancelled(touches, withEvent: event)
shrink()
pulseEnded(touches, withEvent: event)
......@@ -108,7 +108,7 @@ public class MaterialButton : UIButton {
// :name: prepareView
//
internal func prepareView() {
setTranslatesAutoresizingMaskIntoConstraints(false)
translatesAutoresizingMaskIntoConstraints = false
}
//
......@@ -167,7 +167,7 @@ public class MaterialButton : UIButton {
// :name: prepareBackgroundColorView
//
private func prepareBackgroundColorView() {
backgroundColorView.setTranslatesAutoresizingMaskIntoConstraints(false)
backgroundColorView.translatesAutoresizingMaskIntoConstraints = false
backgroundColorView.layer.masksToBounds = true
backgroundColorView.clipsToBounds = true
backgroundColorView.userInteractionEnabled = false
......@@ -183,7 +183,7 @@ public class MaterialButton : UIButton {
delay: 0,
usingSpringWithDamping: 0.2,
initialSpringVelocity: 10,
options: nil,
options: [],
animations: {
self.transform = CGAffineTransformIdentity
},
......
......@@ -54,7 +54,7 @@ public class MaterialCardView : UIView {
/**
:name: init
*/
public required init(coder aDecoder: NSCoder) {
public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
prepareView()
}
......@@ -77,7 +77,7 @@ public class MaterialCardView : UIView {
/**
:name: touchesBegan
*/
public override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
public override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesBegan(touches, withEvent: event)
pulseBegan(touches, withEvent: event)
}
......@@ -85,7 +85,7 @@ public class MaterialCardView : UIView {
/**
:name: touchesEnded
*/
public override func touchesEnded(touches: Set<NSObject>, withEvent event: UIEvent) {
public override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesEnded(touches, withEvent: event)
shrink()
pulseEnded(touches, withEvent: event)
......@@ -94,7 +94,7 @@ public class MaterialCardView : UIView {
/**
:name: touchesCancelled
*/
public override func touchesCancelled(touches: Set<NSObject>!, withEvent event: UIEvent!) {
public override func touchesCancelled(touches: Set<UITouch>?, withEvent event: UIEvent?) {
super.touchesCancelled(touches, withEvent: event)
shrink()
pulseEnded(touches, withEvent: event)
......@@ -104,7 +104,7 @@ public class MaterialCardView : UIView {
// :name: prepareView
//
internal func prepareView() {
setTranslatesAutoresizingMaskIntoConstraints(false)
translatesAutoresizingMaskIntoConstraints = false
prepareBackgroundColorView()
preparePulseViewContainer()
prepareCard()
......@@ -146,7 +146,7 @@ public class MaterialCardView : UIView {
//
// :name: pulseBegan
//
internal func pulseBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
internal func pulseBegan(touches: Set<NSObject>, withEvent event: UIEvent?) {
let width: CGFloat = bounds.size.width / 3
pulseView = UIView(frame: CGRectMake(0, 0, width, width))
pulseView!.layer.cornerRadius = width / 2
......@@ -164,7 +164,7 @@ public class MaterialCardView : UIView {
//
// :name: pulseEnded
//
internal func pulseEnded(touches: Set<NSObject>, withEvent event: UIEvent) {
internal func pulseEnded(touches: Set<NSObject>?, withEvent event: UIEvent?) {
UIView.animateWithDuration(0.3,
animations: { _ in
self.pulseView?.alpha = 0
......@@ -182,7 +182,7 @@ public class MaterialCardView : UIView {
// We need this view so we can use the masksToBounds
// so the pulse doesn't animate off the button
private func prepareBackgroundColorView() {
backgroundColorView.setTranslatesAutoresizingMaskIntoConstraints(false)
backgroundColorView.translatesAutoresizingMaskIntoConstraints = false
backgroundColorView.layer.cornerRadius = 2
backgroundColorView.layer.masksToBounds = true
backgroundColorView.clipsToBounds = true
......@@ -197,7 +197,7 @@ public class MaterialCardView : UIView {
// We need this view so we can use the masksToBounds
// so the pulse doesn't animate off the button
private func preparePulseViewContainer() {
pulseViewContainer.setTranslatesAutoresizingMaskIntoConstraints(false)
pulseViewContainer.translatesAutoresizingMaskIntoConstraints = false
pulseViewContainer.layer.cornerRadius = 2
pulseViewContainer.layer.masksToBounds = true
pulseViewContainer.clipsToBounds = true
......@@ -212,7 +212,7 @@ public class MaterialCardView : UIView {
delay: 0,
usingSpringWithDamping: 0.2,
initialSpringVelocity: 10,
options: nil,
options: [],
animations: {
self.transform = CGAffineTransformIdentity
},
......
......@@ -34,7 +34,7 @@ public class MaterialText: NSObject {
*/
public var searchPattern: String = "(^|\\s)#[\\d\\w_\u{203C}\u{2049}\u{20E3}\u{2122}\u{2139}\u{2194}-\u{2199}\u{21A9}-\u{21AA}\u{231A}-\u{231B}\u{23E9}-\u{23EC}\u{23F0}\u{23F3}\u{24C2}\u{25AA}-\u{25AB}\u{25B6}\u{25C0}\u{25FB}-\u{25FE}\u{2600}-\u{2601}\u{260E}\u{2611}\u{2614}-\u{2615}\u{261D}\u{263A}\u{2648}-\u{2653}\u{2660}\u{2663}\u{2665}-\u{2666}\u{2668}\u{267B}\u{267F}\u{2693}\u{26A0}-\u{26A1}\u{26AA}-\u{26AB}\u{26BD}-\u{26BE}\u{26C4}-\u{26C5}\u{26CE}\u{26D4}\u{26EA}\u{26F2}-\u{26F3}\u{26F5}\u{26FA}\u{26FD}\u{2702}\u{2705}\u{2708}-\u{270C}\u{270F}\u{2712}\u{2714}\u{2716}\u{2728}\u{2733}-\u{2734}\u{2744}\u{2747}\u{274C}\u{274E}\u{2753}-\u{2755}\u{2757}\u{2764}\u{2795}-\u{2797}\u{27A1}\u{27B0}\u{2934}-\u{2935}\u{2B05}-\u{2B07}\u{2B1B}-\u{2B1C}\u{2B50}\u{2B55}\u{3030}\u{303D}\u{3297}\u{3299}\u{1F004}\u{1F0CF}\u{1F170}-\u{1F171}\u{1F17E}-\u{1F17F}\u{1F18E}\u{1F191}-\u{1F19A}\u{1F1E7}-\u{1F1EC}\u{1F1EE}-\u{1F1F0}\u{1F1F3}\u{1F1F5}\u{1F1F7}-\u{1F1FA}\u{1F201}-\u{1F202}\u{1F21A}\u{1F22F}\u{1F232}-\u{1F23A}\u{1F250}-\u{1F251}\u{1F300}-\u{1F320}\u{1F330}-\u{1F335}\u{1F337}-\u{1F37C}\u{1F380}-\u{1F393}\u{1F3A0}-\u{1F3C4}\u{1F3C6}-\u{1F3CA}\u{1F3E0}-\u{1F3F0}\u{1F400}-\u{1F43E}\u{1F440}\u{1F442}-\u{1F4F7}\u{1F4F9}-\u{1F4FC}\u{1F500}-\u{1F507}\u{1F509}-\u{1F53D}\u{1F550}-\u{1F567}\u{1F5FB}-\u{1F640}\u{1F645}-\u{1F64F}\u{1F680}-\u{1F68A}]+" {
didSet {
textStorage.searchExpression = NSRegularExpression(pattern: searchPattern, options: nil, error: nil)
textStorage.searchExpression = try? NSRegularExpression(pattern: searchPattern, options: [])
}
}
......@@ -56,7 +56,7 @@ public class MaterialText: NSObject {
public override init() {
textStorage = MaterialTextStorage()
super.init()
textStorage.searchExpression = NSRegularExpression(pattern: searchPattern, options: nil, error: nil)
textStorage.searchExpression = try? NSRegularExpression(pattern: searchPattern, options: [])
textStorage.textStorageWillProcessEdit = { (textStorage: MaterialTextStorage, string: String, range: NSRange) -> Void in
self.delegate?.textStorageWillProcessEdit?(self, textStorage: textStorage, string: string, range: range)
}
......@@ -82,8 +82,8 @@ public class MaterialText: NSObject {
*/
public var matches: Array<String> {
get {
let results: Array<NSTextCheckingResult> = textStorage.searchExpression!.matchesInString(string, options: nil, range: NSMakeRange(0, count(string.utf16))) as! Array<NSTextCheckingResult>
return unique(map(results) {(self.string as NSString).substringWithRange($0.range)})
let results: Array<NSTextCheckingResult> = textStorage.searchExpression!.matchesInString(string, options: [], range: NSMakeRange(0, string.utf16.count))
return unique(results.map {(self.string as NSString).substringWithRange($0.range)})
}
}
......@@ -93,6 +93,6 @@ public class MaterialText: NSObject {
*/
private func unique<S: SequenceType, E: Hashable where E == S.Generator.Element>(source: S) -> [E] {
var seen: [E:Bool] = [:]
return filter(source) {nil == seen.updateValue(true, forKey: $0)}
return source.filter {nil == seen.updateValue(true, forKey: $0)}
}
}
\ No newline at end of file
......@@ -48,7 +48,7 @@ public class MaterialTextStorage: NSTextStorage {
*/
internal var textStorageDidProcessEdit: MaterialTextStorageDidProcessEdit?
required public init(coder aDecoder: NSCoder) {
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
......@@ -69,22 +69,22 @@ public class MaterialTextStorage: NSTextStorage {
override public func processEditing() {
let range: NSRange = (string as NSString).paragraphRangeForRange(editedRange)
textStorageWillProcessEdit?(self, string, range)
searchExpression!.enumerateMatchesInString(string, options: nil, range: range) { (result: NSTextCheckingResult!, flags: NSMatchingFlags, stop: UnsafeMutablePointer<ObjCBool>) in
searchExpression!.enumerateMatchesInString(string, options: [], range: range) { (result: NSTextCheckingResult!, flags: NSMatchingFlags, stop: UnsafeMutablePointer<ObjCBool>) in
self.textStorageDidProcessEdit?(self, result, flags, stop)
}
super.processEditing()
}
override public func attributesAtIndex(location: Int, effectiveRange range: NSRangePointer) -> [NSObject : AnyObject] {
override public func attributesAtIndex(location: Int, effectiveRange range: NSRangePointer) -> [String : AnyObject] {
return store.attributesAtIndex(location, effectiveRange: range)
}
override public func replaceCharactersInRange(range: NSRange, withString str: String) {
store.replaceCharactersInRange(range, withString: str)
edited(NSTextStorageEditActions.EditedCharacters, range: range, changeInLength: count(str.utf16) - range.length)
edited(NSTextStorageEditActions.EditedCharacters, range: range, changeInLength: str.utf16.count - range.length)
}
override public func setAttributes(attrs: [NSObject : AnyObject]?, range: NSRange) {
override public func setAttributes(attrs: [String : AnyObject]?, range: NSRange) {
store.setAttributes(attrs, range: range)
edited(NSTextStorageEditActions.EditedAttributes, range: range, changeInLength: 0)
}
......
......@@ -40,7 +40,7 @@ public enum SideNavigationViewState {
}
@objc(SideNavigationViewContainer)
public class SideNavigationViewContainer : Printable {
public class SideNavigationViewContainer : NSObject {
/**
:name: state
*/
......@@ -59,7 +59,7 @@ public class SideNavigationViewContainer : Printable {
/**
:name: description
*/
public var description: String {
public override var description: String {
let s: String = .Opened == state ? "Opened" : "Closed"
return "(state: \(s), point: \(point), frame: \(frame))"
}
......@@ -362,7 +362,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
/**
:name: init
*/
public required init(coder aDecoder: NSCoder) {
public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
......@@ -548,28 +548,28 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
:name: toggleLeftViewContainer
*/
public func toggleLeftViewContainer(velocity: CGFloat = 0) {
isLeftContainerOpened ? closeLeftViewContainer(velocity: velocity) : openLeftViewContainer(velocity: velocity)
isLeftContainerOpened ? closeLeftViewContainer(velocity) : openLeftViewContainer(velocity)
}
/**
:name: toggleRightViewContainer
*/
public func toggleRightViewContainer(velocity: CGFloat = 0) {
isRightContainerOpened ? closeRightViewContainer(velocity: velocity) : openRightViewContainer(velocity: velocity)
isRightContainerOpened ? closeRightViewContainer(velocity) : openRightViewContainer(velocity)
}
/**
:name: toggleBottomViewContainer
*/
public func toggleBottomViewContainer(velocity: CGFloat = 0) {
isBottomContainerOpened ? closeBottomViewContainer(velocity: velocity) : openBottomViewContainer(velocity: velocity)
isBottomContainerOpened ? closeBottomViewContainer(velocity) : openBottomViewContainer(velocity)
}
/**
:name: toggleTopViewContainer
*/
public func toggleTopViewContainer(velocity: CGFloat = 0) {
isTopContainerOpened ? closeTopViewContainer(velocity: velocity) : openTopViewContainer(velocity: velocity)
isTopContainerOpened ? closeTopViewContainer(velocity) : openTopViewContainer(velocity)
}
/**
......@@ -940,7 +940,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
if let c = leftContainer {
if .Began == gesture.state {
addShadow(&leftViewContainer)
toggleStatusBar(hide: true)
toggleStatusBar(true)
c.state = isLeftContainerOpened ? .Opened : .Closed
c.point = gesture.locationInView(view)
c.frame = vc.frame
......@@ -959,9 +959,9 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
let x: CGFloat = c.point.x >= 1000 || c.point.x <= -1000 ? c.point.x : 0
c.state = vc.frame.origin.x <= CGFloat(floor(leftOriginX)) + options.horizontalThreshold || c.point.x <= -1000 ? .Closed : .Opened
if .Closed == c.state {
closeLeftViewContainer(velocity: x)
closeLeftViewContainer(x)
} else {
openLeftViewContainer(velocity: x)
openLeftViewContainer(x)
}
delegate?.sideNavDidEndLeftPan?(self, container: c)
}
......@@ -991,7 +991,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
c.state = isRightContainerOpened ? .Opened : .Closed
c.frame = vc.frame
addShadow(&rightViewContainer)
toggleStatusBar(hide: true)
toggleStatusBar(true)
delegate?.sideNavDidBeginRightPan?(self, container: c)
} else if .Changed == gesture.state {
c.point = gesture.translationInView(gesture.view!)
......@@ -1006,9 +1006,9 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
let x: CGFloat = c.point.x <= -1000 || c.point.x >= 1000 ? c.point.x : 0
c.state = vc.frame.origin.x >= CGFloat(floor(rightOriginX) - options.horizontalThreshold) || c.point.x >= 1000 ? .Closed : .Opened
if .Closed == c.state {
closeRightViewContainer(velocity: x)
closeRightViewContainer(x)
} else {
openRightViewContainer(velocity: x)
openRightViewContainer(x)
}
delegate?.sideNavDidEndRightPan?(self, container: c)
}
......@@ -1035,7 +1035,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
if let c = bottomContainer {
if .Began == gesture.state {
addShadow(&bottomViewContainer)
toggleStatusBar(hide: true)
toggleStatusBar(true)
c.state = isBottomContainerOpened ? .Opened : .Closed
c.point = gesture.locationInView(view)
c.frame = vc.frame
......@@ -1053,9 +1053,9 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
let y: CGFloat = c.point.y <= -1000 || c.point.y >= 1000 ? c.point.y : 0
c.state = vc.frame.origin.y >= CGFloat(floor(bottomOriginY) - options.verticalThreshold) || c.point.y >= 1000 ? .Closed : .Opened
if .Closed == c.state {
closeBottomViewContainer(velocity: y)
closeBottomViewContainer(y)
} else {
openBottomViewContainer(velocity: y)
openBottomViewContainer(y)
}
delegate?.sideNavDidEndBottomPan?(self, container: c)
}
......@@ -1082,7 +1082,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
if let c = topContainer {
if .Began == gesture.state {
addShadow(&topViewContainer)
toggleStatusBar(hide: true)
toggleStatusBar(true)
c.state = isTopContainerOpened ? .Opened : .Closed
c.point = gesture.locationInView(view)
c.frame = vc.frame
......@@ -1100,9 +1100,9 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
let y: CGFloat = c.point.y <= -1000 || c.point.y >= 1000 ? c.point.y : 0
c.state = vc.frame.origin.y >= CGFloat(floor(topOriginY) + options.verticalThreshold) || c.point.y >= 1000 ? .Opened : .Closed
if .Closed == c.state {
closeTopViewContainer(velocity: y)
closeTopViewContainer(y)
} else {
openTopViewContainer(velocity: y)
openTopViewContainer(y)
}
delegate?.sideNavDidEndTopPan?(self, container: c)
}
......@@ -1243,7 +1243,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
private func prepareMainContainer() {
mainViewContainer = UIView(frame: view.bounds)
mainViewContainer!.backgroundColor = MaterialTheme.clear.color
mainViewContainer!.autoresizingMask = .FlexibleHeight | .FlexibleWidth
mainViewContainer!.autoresizingMask = [.FlexibleHeight, .FlexibleWidth]
view.addSubview(mainViewContainer!)
}
......@@ -1253,7 +1253,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
private func prepareBackdropContainer() {
backdropViewContainer = UIView(frame: view.bounds)
backdropViewContainer!.backgroundColor = options.backdropBackgroundColor
backdropViewContainer!.autoresizingMask = .FlexibleHeight | .FlexibleWidth
backdropViewContainer!.autoresizingMask = [.FlexibleHeight, .FlexibleWidth]
backdropViewContainer!.layer.opacity = 0
view.addSubview(backdropViewContainer!)
}
......@@ -1311,7 +1311,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
//
private func prepareContainerToOpen(inout viewController: UIViewController?, inout viewContainer: UIView?, state: SideNavigationViewState) {
addShadow(&viewContainer)
toggleStatusBar(hide: true)
toggleStatusBar(true)
}
//
......@@ -1327,7 +1327,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
private func prepareContainedViewController(inout viewContainer: UIView?, inout viewController: UIViewController?) {
if let vc = viewController {
if let c = viewContainer {
vc.view.setTranslatesAutoresizingMaskIntoConstraints(false)
vc.view.translatesAutoresizingMaskIntoConstraints = false
addChildViewController(vc)
c.addSubview(vc.view)
Layout.expandToParent(c, child: vc.view)
......
......@@ -27,7 +27,7 @@ public class TextView: UITextView {
/**
:name: init
*/
public required init(coder aDecoder: NSCoder) {
public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
prepareView()
}
......@@ -38,7 +38,7 @@ public class TextView: UITextView {
public override init(frame: CGRect, textContainer: NSTextContainer?) {
super.init(frame: frame, textContainer: textContainer)
if CGRectZero == frame {
setTranslatesAutoresizingMaskIntoConstraints(false)
translatesAutoresizingMaskIntoConstraints = false
}
prepareView()
}
......@@ -58,7 +58,7 @@ public class TextView: UITextView {
public var placeholderLabel: UILabel? {
didSet {
if let p = placeholderLabel {
p.setTranslatesAutoresizingMaskIntoConstraints(false)
p.translatesAutoresizingMaskIntoConstraints = false
p.font = font
p.textAlignment = textAlignment
p.numberOfLines = 0
......@@ -137,7 +137,7 @@ public class TextView: UITextView {
if let p = placeholderLabel {
NSLayoutConstraint.deactivateConstraints(layoutConstraints)
layoutConstraints = Layout.constraint("H:|-(left)-[placeholderLabel]-(right)-|",
options: nil,
options: [],
metrics: [
"left": textContainerInset.left + textContainer.lineFragmentPadding,
"right": textContainerInset.right + textContainer.lineFragmentPadding
......@@ -146,7 +146,7 @@ public class TextView: UITextView {
])
layoutConstraints += Layout.constraint("V:|-(top)-[placeholderLabel]-(>=bottom)-|",
options: nil,
options: [],
metrics: [
"top": textContainerInset.top,
"bottom": textContainerInset.bottom
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment