From 84dc279c3889b71425128e78a7e993604cd568e7 Mon Sep 17 00:00:00 2001 From: Tom Bachant Date: Mon, 10 Sep 2018 21:52:35 -0400 Subject: [PATCH] feat: remove argument name for string input --- .gitignore | 1 + InitialsImageView.podspec | 6 +++--- InitialsImageView.swift | 10 +++++----- .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++++++ .../InitialsImageViewSampleSwift/ViewController.swift | 4 ++-- 5 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 InitialsImageViewSampleSwift/InitialsImageViewSampleSwift.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/.gitignore b/.gitignore index 2c22487..8c160d2 100644 --- a/.gitignore +++ b/.gitignore @@ -63,3 +63,4 @@ fastlane/report.xml fastlane/Preview.html fastlane/screenshots fastlane/test_output +.DS_Store diff --git a/InitialsImageView.podspec b/InitialsImageView.podspec index 5e36059..8479cfc 100644 --- a/InitialsImageView.podspec +++ b/InitialsImageView.podspec @@ -1,15 +1,15 @@ Pod::Spec.new do |s| s.name = "InitialsImageView" - s.version = "0.2.0" + s.version = "0.3.0" s.summary = "A simple UIImageView extension for using initials as a profile image, written in swift" s.description = "An easy, helpful UIImageView extension that generates letter initials as a placeholder for user profile images, with a randomized background color." s.homepage = "https://github.com/bachonk/InitialsImageView" - s.screenshots = "http://i.imgur.com/xSBjVQ7.png" + s.screenshots = "https://i.imgur.com/KE8OfrL.png" s.license = { :type => 'MIT', :file => 'LICENSE' } s.author = { "Tom Bachant" => "tom@dashride.com" } s.platform = :ios, '8.0' s.source = { :git => "https://github.com/bachonk/InitialsImageView.git", - :tag => '0.2.0' } + :tag => '0.3.0' } s.source_files = 'InitialsImageView.swift' s.requires_arc = true end diff --git a/InitialsImageView.swift b/InitialsImageView.swift index 285311f..f5d3d3f 100644 --- a/InitialsImageView.swift +++ b/InitialsImageView.swift @@ -20,17 +20,17 @@ let kGradientBotomOffset: HSVOffset = (hue: 0.025, saturation: -0.05, brightness extension UIImageView { - public func setImageForName(string: String, backgroundColor: UIColor? = nil, circular: Bool, textAttributes: [NSAttributedStringKey: AnyObject]?, gradient: Bool = false) { + public func setImageForName(_ string: String, backgroundColor: UIColor? = nil, circular: Bool, textAttributes: [NSAttributedStringKey: AnyObject]?, gradient: Bool = false) { - setImageForName(string: string, backgroundColor: backgroundColor, circular: circular, textAttributes: textAttributes, gradient: gradient, gradientColors: nil) + setImageForName(string, backgroundColor: backgroundColor, circular: circular, textAttributes: textAttributes, gradient: gradient, gradientColors: nil) } - public func setImageForName(string: String, gradientColors: GradientColors, circular: Bool, textAttributes: [NSAttributedStringKey: AnyObject]?) { + public func setImageForName(_ string: String, gradientColors: GradientColors, circular: Bool, textAttributes: [NSAttributedStringKey: AnyObject]?) { - setImageForName(string: string, backgroundColor: nil, circular: circular, textAttributes: textAttributes, gradient: true, gradientColors: gradientColors) + setImageForName(string, backgroundColor: nil, circular: circular, textAttributes: textAttributes, gradient: true, gradientColors: gradientColors) } - private func setImageForName(string: String, backgroundColor: UIColor?, circular: Bool, textAttributes: [NSAttributedStringKey: AnyObject]?, gradient: Bool = false, gradientColors: GradientColors?) { + private func setImageForName(_ string: String, backgroundColor: UIColor?, circular: Bool, textAttributes: [NSAttributedStringKey: AnyObject]?, gradient: Bool = false, gradientColors: GradientColors?) { let initials: String = initialsFromString(string: string) let color: UIColor = (backgroundColor != nil) ? backgroundColor! : randomColor(for: string) diff --git a/InitialsImageViewSampleSwift/InitialsImageViewSampleSwift.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/InitialsImageViewSampleSwift/InitialsImageViewSampleSwift.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/InitialsImageViewSampleSwift/InitialsImageViewSampleSwift.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/InitialsImageViewSampleSwift/InitialsImageViewSampleSwift/ViewController.swift b/InitialsImageViewSampleSwift/InitialsImageViewSampleSwift/ViewController.swift index b30c5a7..dfe1ffa 100644 --- a/InitialsImageViewSampleSwift/InitialsImageViewSampleSwift/ViewController.swift +++ b/InitialsImageViewSampleSwift/InitialsImageViewSampleSwift/ViewController.swift @@ -18,13 +18,13 @@ class ViewController: UIViewController { let randomImage: UIImageView = UIImageView.init(frame: CGRect(x: self.view.bounds.midX - 40, y: self.view.bounds.midY - 80 - 40, width: 80, height: 80)) self.view.addSubview(randomImage) - randomImage.setImageForName(string: "Hello World", circular: true, textAttributes: nil, gradient: true) + randomImage.setImageForName("Hello World", circular: true, textAttributes: nil, gradient: true) // More specific option with bg color and font specified let customImage: UIImageView = UIImageView.init(frame: CGRect(x: self.view.bounds.midX - 40, y: self.view.bounds.midY + 40, width: 80, height: 80)) self.view.addSubview(customImage) - customImage.setImageForName(string: "Custom Font", backgroundColor: .blue, circular: true, textAttributes: [NSAttributedStringKey(rawValue: NSAttributedStringKey.font.rawValue): UIFont(name: "AmericanTypewriter-Bold", size: 30)!, NSAttributedStringKey(rawValue: NSAttributedStringKey.foregroundColor.rawValue): UIColor.init(white: 1.0, alpha: 0.5)]) + customImage.setImageForName("Custom Font", backgroundColor: .blue, circular: true, textAttributes: [NSAttributedStringKey(rawValue: NSAttributedStringKey.font.rawValue): UIFont(name: "AmericanTypewriter-Bold", size: 30)!, NSAttributedStringKey(rawValue: NSAttributedStringKey.foregroundColor.rawValue): UIColor.init(white: 1.0, alpha: 0.5)]) }