diff --git a/Extras/SingleShotOffscreenLabel.swift b/Extras/SingleShotOffscreenLabel.swift index 4b765bbc..da041c64 100644 --- a/Extras/SingleShotOffscreenLabel.swift +++ b/Extras/SingleShotOffscreenLabel.swift @@ -27,7 +27,7 @@ open class SingleShotOffscreenLabel: MarqueeLabel { } } - public func pauseAndClear() { + @objc public func pauseAndClear() { // Pause label offscreen pauseLabel() // Change text to nil diff --git a/MarqueeLabelSwift/MarqueeLabelDemoViewController.swift b/MarqueeLabelSwift/MarqueeLabelDemoViewController.swift index 7b266d9c..4cc8ee04 100644 --- a/MarqueeLabelSwift/MarqueeLabelDemoViewController.swift +++ b/MarqueeLabelSwift/MarqueeLabelDemoViewController.swift @@ -64,10 +64,10 @@ class MarqueeLabelDemoViewController : UIViewController { demoLabel2.leadingBuffer = 40.0 let attributedString2 = NSMutableAttributedString(string:"This is a long string, that's also an attributed string, which works just as well!") - attributedString2.addAttribute(NSFontAttributeName, value: UIFont(name: "Helvetica-Bold", size: 18)!, range: NSMakeRange(0, 21)) - attributedString2.addAttribute(NSBackgroundColorAttributeName, value: UIColor.lightGray, range: NSMakeRange(0, 14)) - attributedString2.addAttribute(NSForegroundColorAttributeName, value: UIColor(red: 0.234, green: 0.234, blue: 0.234, alpha: 1.0), range: NSMakeRange(0, attributedString2.length)) - attributedString2.addAttribute(NSFontAttributeName, value: UIFont(name: "HelveticaNeue-Light", size: 18)!, range: NSMakeRange(21, attributedString2.length - 21)) + attributedString2.addAttribute(NSAttributedStringKey.font, value: UIFont(name: "Helvetica-Bold", size: 18)!, range: NSMakeRange(0, 21)) + attributedString2.addAttribute(NSAttributedStringKey.backgroundColor, value: UIColor.lightGray, range: NSMakeRange(0, 14)) + attributedString2.addAttribute(NSAttributedStringKey.foregroundColor, value: UIColor(red: 0.234, green: 0.234, blue: 0.234, alpha: 1.0), range: NSMakeRange(0, attributedString2.length)) + attributedString2.addAttribute(NSAttributedStringKey.font, value: UIFont(name: "HelveticaNeue-Light", size: 18)!, range: NSMakeRange(21, attributedString2.length - 21)) demoLabel2.attributedText = attributedString2 @@ -114,10 +114,10 @@ class MarqueeLabelDemoViewController : UIViewController { demoLabel6.trailingBuffer = 30.0 let attributedString6 = NSMutableAttributedString(string:"This is a long, attributed string, that's set up to loop in a continuous fashion!") - attributedString6.addAttribute(NSForegroundColorAttributeName, value: UIColor(red: 0.123, green: 0.331, blue: 0.657, alpha: 1.000), range: NSMakeRange(0,34)) - attributedString6.addAttribute(NSForegroundColorAttributeName, value: UIColor(red: 0.657, green: 0.096, blue: 0.088, alpha: 1.000), range: NSMakeRange(34, attributedString6.length - 34)) - attributedString6.addAttribute(NSFontAttributeName, value: UIFont(name: "HelveticaNeue-Light", size:18.0)!, range: NSMakeRange(0, 16)) - attributedString6.addAttribute(NSFontAttributeName, value: UIFont(name: "HelveticaNeue-Light", size:18.0)!, range: NSMakeRange(33, attributedString6.length - 33)) + attributedString6.addAttribute(NSAttributedStringKey.foregroundColor, value: UIColor(red: 0.123, green: 0.331, blue: 0.657, alpha: 1.000), range: NSMakeRange(0,34)) + attributedString6.addAttribute(NSAttributedStringKey.foregroundColor, value: UIColor(red: 0.657, green: 0.096, blue: 0.088, alpha: 1.000), range: NSMakeRange(34, attributedString6.length - 34)) + attributedString6.addAttribute(NSAttributedStringKey.font, value: UIFont(name: "HelveticaNeue-Light", size:18.0)!, range: NSMakeRange(0, 16)) + attributedString6.addAttribute(NSAttributedStringKey.font, value: UIFont(name: "HelveticaNeue-Light", size:18.0)!, range: NSMakeRange(33, attributedString6.length - 33)) demoLabel6.attributedText = attributedString6; } @@ -153,17 +153,17 @@ class MarqueeLabelDemoViewController : UIViewController { demoLabel3.text = "This is a short, centered label." let attributedString2 = NSMutableAttributedString(string: "This is a different longer string, but still an attributed string, with new different attributes!") - attributedString2.addAttribute(NSForegroundColorAttributeName, value: UIColor.black, range: NSMakeRange(0, attributedString2.length)) - attributedString2.addAttribute(NSFontAttributeName, value: UIFont(name: "Helvetica-Bold", size:18.0)!, range:NSMakeRange(0, attributedString2.length)) - attributedString2.addAttribute(NSBackgroundColorAttributeName, value: UIColor(white:0.600, alpha:1.000), range:NSMakeRange(0,33)) - attributedString2.addAttribute(NSFontAttributeName, value: UIFont(name: "HelveticaNeue-Light", size:18.0)!, range:NSMakeRange(19, attributedString2.length - 19)) + attributedString2.addAttribute(NSAttributedStringKey.foregroundColor, value: UIColor.black, range: NSMakeRange(0, attributedString2.length)) + attributedString2.addAttribute(NSAttributedStringKey.font, value: UIFont(name: "Helvetica-Bold", size:18.0)!, range:NSMakeRange(0, attributedString2.length)) + attributedString2.addAttribute(NSAttributedStringKey.backgroundColor, value: UIColor(white:0.600, alpha:1.000), range:NSMakeRange(0,33)) + attributedString2.addAttribute(NSAttributedStringKey.font, value: UIFont(name: "HelveticaNeue-Light", size:18.0)!, range:NSMakeRange(19, attributedString2.length - 19)) demoLabel2.attributedText = attributedString2; let attributedString6 = NSMutableAttributedString(string: "This is a different, longer, attributed string, that's set up to loop in a continuous fashion!") - attributedString6.addAttribute(NSForegroundColorAttributeName, value:UIColor(red:0.657, green:0.078, blue:0.067, alpha:1.000), range:NSMakeRange(0,attributedString6.length)) - attributedString6.addAttribute(NSFontAttributeName, value:UIFont(name: "HelveticaNeue-Light", size:18.0)!, range:NSMakeRange(0, 16)) - attributedString6.addAttribute(NSFontAttributeName, value:UIFont(name: "HelveticaNeue-Light", size:18.0)!, range:NSMakeRange(33, attributedString6.length - 33)) - attributedString6.addAttribute(NSForegroundColorAttributeName, value: UIColor(red:0.123, green:0.331, blue:0.657, alpha:1.000), range:NSMakeRange(33, attributedString6.length - 33)) + attributedString6.addAttribute(NSAttributedStringKey.foregroundColor, value:UIColor(red:0.657, green:0.078, blue:0.067, alpha:1.000), range:NSMakeRange(0,attributedString6.length)) + attributedString6.addAttribute(NSAttributedStringKey.font, value:UIFont(name: "HelveticaNeue-Light", size:18.0)!, range:NSMakeRange(0, 16)) + attributedString6.addAttribute(NSAttributedStringKey.font, value:UIFont(name: "HelveticaNeue-Light", size:18.0)!, range:NSMakeRange(33, attributedString6.length - 33)) + attributedString6.addAttribute(NSAttributedStringKey.foregroundColor, value: UIColor(red:0.123, green:0.331, blue:0.657, alpha:1.000), range:NSMakeRange(33, attributedString6.length - 33)) demoLabel6.attributedText = attributedString6; demoLabel1.tag = 102; @@ -172,23 +172,23 @@ class MarqueeLabelDemoViewController : UIViewController { demoLabel3.text = "That also scrolls left, then right, rather than in a continuous loop!" let attributedString2 = NSMutableAttributedString(string: "This is a long string, that's also an attributed string, which works just as well!") - attributedString2.addAttribute(NSFontAttributeName, value: UIFont(name: "Helvetica-Bold", size:18.0)!, range:NSMakeRange(0, 21)) - attributedString2.addAttribute(NSBackgroundColorAttributeName, value: UIColor.lightGray, range:NSMakeRange(10,11)) - attributedString2.addAttribute(NSForegroundColorAttributeName, value: UIColor(red:0.234, green:0.234, blue:0.234, alpha:1.000), range:NSMakeRange(0,attributedString2.length)) - attributedString2.addAttribute(NSFontAttributeName, value: UIFont(name: "HelveticaNeue-Light", size:18.0)!, range: NSMakeRange(21, attributedString2.length - 21)) + attributedString2.addAttribute(NSAttributedStringKey.font, value: UIFont(name: "Helvetica-Bold", size:18.0)!, range:NSMakeRange(0, 21)) + attributedString2.addAttribute(NSAttributedStringKey.backgroundColor, value: UIColor.lightGray, range:NSMakeRange(10,11)) + attributedString2.addAttribute(NSAttributedStringKey.foregroundColor, value: UIColor(red:0.234, green:0.234, blue:0.234, alpha:1.000), range:NSMakeRange(0,attributedString2.length)) + attributedString2.addAttribute(NSAttributedStringKey.font, value: UIFont(name: "HelveticaNeue-Light", size:18.0)!, range: NSMakeRange(21, attributedString2.length - 21)) demoLabel2.attributedText = attributedString2 let attributedString6 = NSMutableAttributedString(string: "This is a long, attributed string, that's set up to loop in a continuous fashion!") - attributedString6.addAttribute(NSForegroundColorAttributeName, value:UIColor(red:0.123, green:0.331, blue:0.657, alpha:1.000), range:NSMakeRange(0,attributedString6.length)) - attributedString6.addAttribute(NSFontAttributeName, value:UIFont(name: "HelveticaNeue-Light", size:18.0)!, range:NSMakeRange(0, 16)) - attributedString6.addAttribute(NSFontAttributeName, value:UIFont(name: "HelveticaNeue-Light", size:18.0)!, range:NSMakeRange(33, attributedString6.length - 33)) + attributedString6.addAttribute(NSAttributedStringKey.foregroundColor, value:UIColor(red:0.123, green:0.331, blue:0.657, alpha:1.000), range:NSMakeRange(0,attributedString6.length)) + attributedString6.addAttribute(NSAttributedStringKey.font, value:UIFont(name: "HelveticaNeue-Light", size:18.0)!, range:NSMakeRange(0, 16)) + attributedString6.addAttribute(NSAttributedStringKey.font, value:UIFont(name: "HelveticaNeue-Light", size:18.0)!, range:NSMakeRange(33, attributedString6.length - 33)) demoLabel6.attributedText = attributedString6 demoLabel1.tag = 101; } } - func pauseTap(_ recognizer: UIGestureRecognizer) { + @objc func pauseTap(_ recognizer: UIGestureRecognizer) { let continuousLabel2 = recognizer.view as! MarqueeLabel if recognizer.state == .ended { continuousLabel2.isPaused ? continuousLabel2.unpauseLabel() : continuousLabel2.pauseLabel() diff --git a/MarqueeLabelSwift/MarqueeLabelSwift.xcodeproj/project.pbxproj b/MarqueeLabelSwift/MarqueeLabelSwift.xcodeproj/project.pbxproj index af58bb69..2bc9ece2 100644 --- a/MarqueeLabelSwift/MarqueeLabelSwift.xcodeproj/project.pbxproj +++ b/MarqueeLabelSwift/MarqueeLabelSwift.xcodeproj/project.pbxproj @@ -208,11 +208,11 @@ TargetAttributes = { EA167D011CA8B43700DBF930 = { CreatedOnToolsVersion = 7.3; - LastSwiftMigration = 0800; + LastSwiftMigration = 0910; }; EAE4AC7E1CA8DE70006C1ECC = { CreatedOnToolsVersion = 7.3; - LastSwiftMigration = 0800; + LastSwiftMigration = 0910; }; }; }; @@ -402,7 +402,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.charlespowell.MarqueeLabelSwiftDemo; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -416,7 +417,8 @@ PRODUCT_BUNDLE_IDENTIFIER = com.charlespowell.MarqueeLabelSwiftDemo; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -437,7 +439,8 @@ PRODUCT_BUNDLE_IDENTIFIER = com.charlespowell.MarqueeLabelSwift; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -462,7 +465,8 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; diff --git a/MarqueeLabelTV/MarqueeLabelTV.xcodeproj/project.pbxproj b/MarqueeLabelTV/MarqueeLabelTV.xcodeproj/project.pbxproj index 11fbed83..83a0a5d2 100644 --- a/MarqueeLabelTV/MarqueeLabelTV.xcodeproj/project.pbxproj +++ b/MarqueeLabelTV/MarqueeLabelTV.xcodeproj/project.pbxproj @@ -178,11 +178,11 @@ TargetAttributes = { EA59AC061CAA28D80052AD98 = { CreatedOnToolsVersion = 7.3; - LastSwiftMigration = 0800; + LastSwiftMigration = 0910; }; EAE4ACB51CAA23FD006C1ECC = { CreatedOnToolsVersion = 7.3; - LastSwiftMigration = 0800; + LastSwiftMigration = 0910; }; }; }; @@ -264,7 +264,8 @@ SDKROOT = appletvos; SKIP_INSTALL = YES; SUPPORTED_PLATFORMS = "appletvsimulator appletvos"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; VERSIONING_SYSTEM = "apple-generic"; @@ -291,7 +292,8 @@ SKIP_INSTALL = YES; SUPPORTED_PLATFORMS = "appletvsimulator appletvos"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; VERSIONING_SYSTEM = "apple-generic"; @@ -407,7 +409,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.charlespowell.MarqueeLabelTV; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -421,7 +424,8 @@ PRODUCT_BUNDLE_IDENTIFIER = com.charlespowell.MarqueeLabelTV; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; }; name = Release; }; diff --git a/MarqueeLabelTV/ViewController.swift b/MarqueeLabelTV/ViewController.swift index 2eea24ef..0531664c 100644 --- a/MarqueeLabelTV/ViewController.swift +++ b/MarqueeLabelTV/ViewController.swift @@ -84,7 +84,7 @@ class MarqueeCell: UITableViewCell { } extension UITableViewCell: TextCell { - var cellText: String? { + @objc var cellText: String? { get { return textLabel?.text }