diff --git a/Example-ionicons/Example-ionicons.xcodeproj/project.pbxproj b/Example-ionicons/Example-ionicons.xcodeproj/project.pbxproj index e4f022d..16bb339 100644 --- a/Example-ionicons/Example-ionicons.xcodeproj/project.pbxproj +++ b/Example-ionicons/Example-ionicons.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 307938F01C1728E50034CC99 /* IonButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 307938EF1C1728E50034CC99 /* IonButton.swift */; }; + 30ACE8091C1780D8009EA9E6 /* IonImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30ACE8081C1780D8009EA9E6 /* IonImageView.swift */; }; 554206721821715F005A3D9E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 554206711821715F005A3D9E /* Foundation.framework */; }; 5542067418217160005A3D9E /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 554206731821715F005A3D9E /* CoreGraphics.framework */; }; 5542067618217160005A3D9E /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5542067518217160005A3D9E /* UIKit.framework */; }; @@ -25,7 +27,7 @@ 554206B018217179005A3D9E /* IonIcons.m in Sources */ = {isa = PBXBuildFile; fileRef = 554206AC18217179005A3D9E /* IonIcons.m */; }; 554206B218217179005A3D9E /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 554206AE18217179005A3D9E /* LICENSE */; }; 55E4275C1AE2DB6A00EF1098 /* FontInspector.m in Sources */ = {isa = PBXBuildFile; fileRef = 55E4275B1AE2DB6A00EF1098 /* FontInspector.m */; }; - 55FFA09A1BDBFDD90004F457 /* ionicons.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 55FFA0991BDBFDD90004F457 /* ionicons.bundle */; settings = {ASSET_TAGS = (); }; }; + 55FFA09A1BDBFDD90004F457 /* ionicons.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 55FFA0991BDBFDD90004F457 /* ionicons.bundle */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -39,6 +41,9 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 307938EE1C1728E50034CC99 /* Example-ionicons-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Example-ionicons-Bridging-Header.h"; sourceTree = ""; }; + 307938EF1C1728E50034CC99 /* IonButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IonButton.swift; sourceTree = ""; }; + 30ACE8081C1780D8009EA9E6 /* IonImageView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IonImageView.swift; sourceTree = ""; }; 5542066E1821715F005A3D9E /* Example-ionicons.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Example-ionicons.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 554206711821715F005A3D9E /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 554206731821715F005A3D9E /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; @@ -129,6 +134,7 @@ isa = PBXGroup; children = ( 644532D81BAB270E00DC25F0 /* README.md */, + 307938EE1C1728E50034CC99 /* Example-ionicons-Bridging-Header.h */, 554206A918217179005A3D9E /* ionicons */, 5542068018217160005A3D9E /* AppDelegate.h */, 5542068118217160005A3D9E /* AppDelegate.m */, @@ -182,6 +188,8 @@ 554206AE18217179005A3D9E /* LICENSE */, 55E4275A1AE2DB6A00EF1098 /* FontInspector.h */, 55E4275B1AE2DB6A00EF1098 /* FontInspector.m */, + 307938EF1C1728E50034CC99 /* IonButton.swift */, + 30ACE8081C1780D8009EA9E6 /* IonImageView.swift */, 55FFA0991BDBFDD90004F457 /* ionicons.bundle */, ); name = ionicons; @@ -233,6 +241,7 @@ 554206661821715F005A3D9E /* Project object */ = { isa = PBXProject; attributes = { + LastSwiftUpdateCheck = 0710; LastUpgradeCheck = 0500; ORGANIZATIONNAME = TapTemplate; TargetAttributes = { @@ -305,11 +314,13 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 307938F01C1728E50034CC99 /* IonButton.swift in Sources */, 5542068B18217160005A3D9E /* ViewController.m in Sources */, 5542068218217160005A3D9E /* AppDelegate.m in Sources */, 55E4275C1AE2DB6A00EF1098 /* FontInspector.m in Sources */, 5542067E18217160005A3D9E /* main.m in Sources */, 554206B018217179005A3D9E /* IonIcons.m in Sources */, + 30ACE8091C1780D8009EA9E6 /* IonImageView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -446,10 +457,15 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + CLANG_ENABLE_MODULES = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Example-ionicons/Example-ionicons-Prefix.pch"; INFOPLIST_FILE = "Example-ionicons/Example-ionicons-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "../Example-ionicons/Example-ionicons/Example-ionicons-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; WRAPPER_EXTENSION = app; }; name = Debug; @@ -459,10 +475,14 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + CLANG_ENABLE_MODULES = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Example-ionicons/Example-ionicons-Prefix.pch"; INFOPLIST_FILE = "Example-ionicons/Example-ionicons-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "../Example-ionicons/Example-ionicons/Example-ionicons-Bridging-Header.h"; WRAPPER_EXTENSION = app; }; name = Release; diff --git a/Example-ionicons/Example-ionicons/.DS_Store b/Example-ionicons/Example-ionicons/.DS_Store index 048f053..4c0997b 100644 Binary files a/Example-ionicons/Example-ionicons/.DS_Store and b/Example-ionicons/Example-ionicons/.DS_Store differ diff --git a/Example-ionicons/Example-ionicons/Base.lproj/Main_iPad.storyboard b/Example-ionicons/Example-ionicons/Base.lproj/Main_iPad.storyboard index a185e8a..e517ab5 100644 --- a/Example-ionicons/Example-ionicons/Base.lproj/Main_iPad.storyboard +++ b/Example-ionicons/Example-ionicons/Base.lproj/Main_iPad.storyboard @@ -1,16 +1,22 @@ - + - + + - + + + + + - + + @@ -23,4 +29,4 @@ - \ No newline at end of file + diff --git a/Example-ionicons/Example-ionicons/Base.lproj/Main_iPhone.storyboard b/Example-ionicons/Example-ionicons/Base.lproj/Main_iPhone.storyboard index b99208b..e7f1ac4 100644 --- a/Example-ionicons/Example-ionicons/Base.lproj/Main_iPhone.storyboard +++ b/Example-ionicons/Example-ionicons/Base.lproj/Main_iPhone.storyboard @@ -1,26 +1,45 @@ - + - + + - + + + + + + + + + + + + + + + + + - - - - - - \ No newline at end of file + diff --git a/Example-ionicons/Example-ionicons/Example-ionicons-Bridging-Header.h b/Example-ionicons/Example-ionicons/Example-ionicons-Bridging-Header.h new file mode 100644 index 0000000..c1fec63 --- /dev/null +++ b/Example-ionicons/Example-ionicons/Example-ionicons-Bridging-Header.h @@ -0,0 +1,6 @@ +// +// Use this file to import your target's public headers that you would like to expose to Swift. +// + +#import "ionicons.h" +#import "ionicons-codes.h" \ No newline at end of file diff --git a/Example-ionicons/Example-ionicons/Images.xcassets/AppIcon.appiconset/Contents.json b/Example-ionicons/Example-ionicons/Images.xcassets/AppIcon.appiconset/Contents.json index 91bf9c1..36d2c80 100644 --- a/Example-ionicons/Example-ionicons/Images.xcassets/AppIcon.appiconset/Contents.json +++ b/Example-ionicons/Example-ionicons/Images.xcassets/AppIcon.appiconset/Contents.json @@ -5,16 +5,31 @@ "size" : "29x29", "scale" : "2x" }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, { "idiom" : "iphone", "size" : "40x40", "scale" : "2x" }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, { "idiom" : "iphone", "size" : "60x60", "scale" : "2x" }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, { "idiom" : "ipad", "size" : "29x29", diff --git a/ionicons.podspec b/ionicons.podspec index 75e2d2c..dbd91c9 100644 --- a/ionicons.podspec +++ b/ionicons.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.author = { "David Sweetman" => "david@davidsweetman.com" } s.source = { :git => "https://github.com/sweetmandm/ionicons-iOS.git", :tag => "2.0.3" } s.platform = :ios, '5.0' - s.source_files = 'ionicons/**/*.{h,m}' + s.source_files = 'ionicons/**/*.{h,m,swift}' s.resources = "ionicons/ionicons.bundle" s.requires_arc = true end diff --git a/ionicons/IonButton.swift b/ionicons/IonButton.swift new file mode 100644 index 0000000..099f8a0 --- /dev/null +++ b/ionicons/IonButton.swift @@ -0,0 +1,61 @@ +// +// IonButton.swift +// Example-ionicons +// +// Created by Max Campolo on 12/8/15. +// Copyright © 2015 Max Campolo. All rights reserved. +// + +import UIKit + +@IBDesignable +class IonButton: UIButton { + + /* + // Only override drawRect: if you perform custom drawing. + // An empty implementation adversely affects performance during animation. + override func drawRect(rect: CGRect) { + // Drawing code + } + */ + + required init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + // Other stuff + } + + override init(frame: CGRect) { + super.init(frame: frame) + } + + @IBInspectable var ionIconBackgroundImage: String? { + get { + return self.currentBackgroundImage?.description + } + set { + self.setBackgroundImage(IonIcons.imageWithIcon(self.convertToUnicode(newValue!), size: self.frame.size.width, color: .blackColor()).imageWithRenderingMode(.AlwaysTemplate), forState:UIControlState.Normal) + } + } + + @IBInspectable var ionIconImage: String? { + get { + return self.currentImage?.description + } + set { + self.setImage(IonIcons.imageWithIcon(self.convertToUnicode(newValue!), size: self.frame.size.width, color: .blackColor()).imageWithRenderingMode(.AlwaysTemplate), forState: .Normal) + } + } + + func convertToUnicode(hexString: String) -> String? { + var result: String? + let scanner = NSScanner(string: hexString) + var unicodeInt = UInt32() + if scanner.scanHexInt(&unicodeInt) { + if let unicodeString: NSString = NSString(bytes: &unicodeInt, length: 4, encoding: NSUTF32LittleEndianStringEncoding) { + result = unicodeString as String + } + } + return result + } + +} diff --git a/ionicons/IonImageView.swift b/ionicons/IonImageView.swift new file mode 100644 index 0000000..2ef0033 --- /dev/null +++ b/ionicons/IonImageView.swift @@ -0,0 +1,51 @@ +// +// IonImageView.swift +// Example-ionicons +// +// Created by Max Campolo on 12/8/15. +// Copyright © 2015 Max Campolo. All rights reserved. +// + +import UIKit + +@IBDesignable +class IonImageView: UIImageView { + + /* + // Only override drawRect: if you perform custom drawing. + // An empty implementation adversely affects performance during animation. + override func drawRect(rect: CGRect) { + // Drawing code + } + */ + + required init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + // Other stuff + } + + override init(frame: CGRect) { + super.init(frame: frame) + } + + @IBInspectable var ionIconImage: String? { + get { + return self.image?.description + } + set { + self.image = IonIcons.imageWithIcon(self.convertToUnicode(newValue!), size: self.frame.size.width, color: .blackColor()).imageWithRenderingMode(.AlwaysTemplate) + } + } + + func convertToUnicode(hexString: String) -> String? { + var result: String? + let scanner = NSScanner(string: hexString) + var unicodeInt = UInt32() + if scanner.scanHexInt(&unicodeInt) { + if let unicodeString: NSString = NSString(bytes: &unicodeInt, length: 4, encoding: NSUTF32LittleEndianStringEncoding) { + result = unicodeString as String + } + } + return result + } +}