From be75f2936ab74714bd6a7838749d84dbc6368586 Mon Sep 17 00:00:00 2001 From: Wanny Date: Fri, 13 Feb 2015 11:24:34 -0800 Subject: [PATCH 1/3] fix project warnings --- .../DCRoundSwitchDemo.xcodeproj/project.pbxproj | 9 ++++++--- DCRoundSwitchDemo/Default-568h@2x.png | Bin 0 -> 18594 bytes 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 DCRoundSwitchDemo/Default-568h@2x.png diff --git a/DCRoundSwitchDemo/DCRoundSwitchDemo.xcodeproj/project.pbxproj b/DCRoundSwitchDemo/DCRoundSwitchDemo.xcodeproj/project.pbxproj index e9fbf5d..c072291 100644 --- a/DCRoundSwitchDemo/DCRoundSwitchDemo.xcodeproj/project.pbxproj +++ b/DCRoundSwitchDemo/DCRoundSwitchDemo.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 3D592E4D1A8E86A600F3399B /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 3D592E4C1A8E86A600F3399B /* Default-568h@2x.png */; }; AB6FE5D313C420A3006BCDBB /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB6FE5D213C420A3006BCDBB /* UIKit.framework */; }; AB6FE5D513C420A3006BCDBB /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB6FE5D413C420A3006BCDBB /* Foundation.framework */; }; AB6FE5D713C420A3006BCDBB /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB6FE5D613C420A3006BCDBB /* CoreGraphics.framework */; }; @@ -26,6 +27,7 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 3D592E4C1A8E86A600F3399B /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; AB6FE5CE13C420A3006BCDBB /* DCRoundSwitchDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DCRoundSwitchDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; AB6FE5D213C420A3006BCDBB /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; AB6FE5D413C420A3006BCDBB /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; @@ -74,6 +76,7 @@ AB6FE5C313C420A3006BCDBB = { isa = PBXGroup; children = ( + 3D592E4C1A8E86A600F3399B /* Default-568h@2x.png */, AB6FE5D813C420A3006BCDBB /* DCRoundSwitchDemo */, AB6FE5D113C420A3006BCDBB /* Frameworks */, AB6FE5CF13C420A3006BCDBB /* Products */, @@ -171,7 +174,7 @@ AB6FE5C513C420A3006BCDBB /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0440; + LastUpgradeCheck = 0610; }; buildConfigurationList = AB6FE5C813C420A3006BCDBB /* Build configuration list for PBXProject "DCRoundSwitchDemo" */; compatibilityVersion = "Xcode 3.2"; @@ -197,6 +200,7 @@ buildActionMask = 2147483647; files = ( DA7A60B613FEA495000F7F8D /* MainWindow.xib in Resources */, + 3D592E4D1A8E86A600F3399B /* Default-568h@2x.png in Resources */, DA7A60B813FEA4A2000F7F8D /* DCRoundSwitchDemoViewController.xib in Resources */, DA7A60BC13FEA655000F7F8D /* Localizable.strings in Resources */, ); @@ -239,7 +243,6 @@ AB6FE5ED13C420A3006BCDBB /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_OPTIMIZATION_LEVEL = 0; @@ -249,6 +252,7 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 4.3; + ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; }; name = Debug; @@ -256,7 +260,6 @@ AB6FE5EE13C420A3006BCDBB /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_VERSION = com.apple.compilers.llvmgcc42; diff --git a/DCRoundSwitchDemo/Default-568h@2x.png b/DCRoundSwitchDemo/Default-568h@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..0891b7aabfcf3422423b109c8beed2bab838c607 GIT binary patch literal 18594 zcmeI4X;f257Jx&9fS`ixvS;&$x8J@slQFSel)6zJN=?13FB7H(lQjRkSy8x_-S~tvu2gzn1oS+dLcF#eqtq$ z%tf9TTvX?`)R@}3uBI;jzS-=ZR-Td&MHaS&;!0?Ni*#$#`n*~CcQK)Q9vAQ~TUpnI!j)a2biYK^R)M~A5wUDZhx?ULMX z3x1P&qt=trOY6P2U67L=m=U?F|5#Uj(eCueNTZaHs_ceWiHeET+j+tp3Jt9g(ekqP z2WOvfR{qV+9r+o4J5?qK>7;;^+I7tGv-i)es$X_D=EoKF+S?zsyj^oRFElP}c}JT< zd8SUs-?O?}2YD#ngKbnHgzHBcboxK_2r9l(?eNCl-pEzkJm}fY?WC*jnS?VBE4EpY zO$fEejz6fU;W2Kl>JeQBZBl-%Irg`obSlg*@4QB;Dd1H7^Oi5wvt4d{RZ!8Og?^aE z)k0$1g+V3fd(gdQ3d&q2q-FL*uy#}|bc^=VhFsl0jBgUGJ+-s3U8MK9A!YJJMxpci z5hJ%|{DwV48fZn0{n5l$N_KcSb#NKE4plB`9I6Zt=Z!~-zw0{9tg$L&Ju1F0X)Cy8 zKF;(&lJ>x)Jw(=;p~sF(Sd9VWGwFE2rnyS9!f^DZ8+aCLq zQ};>lcJ1GDLqjm6Hd>|Eabno@P`~Bn(~6^aD_#yoEH(a?Nm1S<;S+hSxI5d16^<1lEM3NPFi zkqPrpL)+ zgnseFikg`gJVBha1&7C4;O6>h=dt~`ND+;Zd?W(4v2JIb7Pt>Td42%M-Ju-XAH#Pns762L}K3 zDhvsRqN0Ni(1UrishD2YvV?4*h2iFj$+&N||Fn$4n|^NSU+o?~jq`0jVQt8T9l{7b zXiwwODFh2V!Q6sqP9S>WH$oOf$N~=d0-bqTlD61!=`&0eAP-F>XN?*|gtOXX{ zQVTWyYo4ZK0GAw!GHf|pz9`D;-bbb*5LBX*{bnz|+)$@&P9|ORM2o?95{;ejvo&r- zq8cBhTN6nn)7~W>54U)%-F_-b?YKdfk5I8MHcuzBD5)!;yv#Z&R&^y=@=>VTIMy#r zX&U<=BsPkdqcMe<_}2+>H%XKyrr5ZR8_KVe>ZqYN z^=^~TFD};;rHJ$U;{~w^hYojl4hRI@SH$^K{YEo=sg)WY87r!*7blQK&qnpDo0`Vn zkl)9u9g=mCh&ZCJS(L4yN3k0kQ zuvg$h2KEEk51T+O0JQ+r0`R>g{jvqM0Mr6d3qUOZwE!?PI7HY@CE|dr sfw?Q;rAv?G4&^^8-z_>&sWXMxvD*gPOU4CBe-*@OtE+wfmVJNyHv)PfH~;_u literal 0 HcmV?d00001 From e84a96bab317d8bdb86a81b9fdb895d405e330b0 Mon Sep 17 00:00:00 2001 From: Wanny Date: Fri, 13 Feb 2015 11:40:51 -0800 Subject: [PATCH 2/3] update iOS Deployment Target to 7.0 --- DCRoundSwitchDemo/DCRoundSwitchDemo.xcodeproj/project.pbxproj | 3 +++ 1 file changed, 3 insertions(+) diff --git a/DCRoundSwitchDemo/DCRoundSwitchDemo.xcodeproj/project.pbxproj b/DCRoundSwitchDemo/DCRoundSwitchDemo.xcodeproj/project.pbxproj index c072291..45ca77c 100644 --- a/DCRoundSwitchDemo/DCRoundSwitchDemo.xcodeproj/project.pbxproj +++ b/DCRoundSwitchDemo/DCRoundSwitchDemo.xcodeproj/project.pbxproj @@ -281,6 +281,8 @@ GCC_PREFIX_HEADER = "DCRoundSwitchDemo/DCRoundSwitchDemo-Prefix.pch"; GCC_VERSION = ""; INFOPLIST_FILE = "DCRoundSwitchDemo/DCRoundSwitchDemo-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 7.0; + ONLY_ACTIVE_ARCH = YES; PRODUCT_NAME = "$(TARGET_NAME)"; RUN_CLANG_STATIC_ANALYZER = YES; WRAPPER_EXTENSION = app; @@ -296,6 +298,7 @@ GCC_PREFIX_HEADER = "DCRoundSwitchDemo/DCRoundSwitchDemo-Prefix.pch"; GCC_VERSION = ""; INFOPLIST_FILE = "DCRoundSwitchDemo/DCRoundSwitchDemo-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 7.0; PRODUCT_NAME = "$(TARGET_NAME)"; RUN_CLANG_STATIC_ANALYZER = YES; VALIDATE_PRODUCT = YES; From 201f7de6c32d90ba5240dbc8a182aa2ae35af767 Mon Sep 17 00:00:00 2001 From: Wanny Date: Fri, 13 Feb 2015 11:53:02 -0800 Subject: [PATCH 3/3] fix deprecated textWithFont related warnings --- DCRoundSwitch/DCRoundSwitch.m | 6 +++--- DCRoundSwitch/DCRoundSwitchToggleLayer.m | 19 ++++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/DCRoundSwitch/DCRoundSwitch.m b/DCRoundSwitch/DCRoundSwitch.m index 8e0549b..76f3a6f 100644 --- a/DCRoundSwitch/DCRoundSwitch.m +++ b/DCRoundSwitch/DCRoundSwitch.m @@ -173,9 +173,9 @@ - (void)sizeToFit NSString *onString = self.toggleLayer.onString; NSString *offString = self.toggleLayer.offString; - CGFloat width = [onString sizeWithFont:self.toggleLayer.labelFont].width; - CGFloat offWidth = [offString sizeWithFont:self.toggleLayer.labelFont].width; - + CGFloat width = [onString sizeWithAttributes:@{NSFontAttributeName: self.toggleLayer.labelFont}].width; + CGFloat offWidth = [offString sizeWithAttributes:@{NSFontAttributeName: self.toggleLayer.labelFont}].width; + if(offWidth > width) width = offWidth; diff --git a/DCRoundSwitch/DCRoundSwitchToggleLayer.m b/DCRoundSwitch/DCRoundSwitchToggleLayer.m index 99e0550..40d18eb 100644 --- a/DCRoundSwitch/DCRoundSwitchToggleLayer.m +++ b/DCRoundSwitch/DCRoundSwitchToggleLayer.m @@ -81,21 +81,22 @@ - (void)drawInContext:(CGContextRef)context UIGraphicsPushContext(context); // 'ON' state label (self.onString) - CGSize onTextSize = [self.onString sizeWithFont:self.labelFont]; + CGSize onTextSize = [self.onString sizeWithAttributes:@{NSFontAttributeName: self.labelFont}]; + CGPoint onTextPoint = CGPointMake((textSpaceWidth - onTextSize.width) / 2.0 + knobRadius * .15, floorf((self.bounds.size.height - onTextSize.height) / 2.0) + 1.0); [[UIColor colorWithWhite:0.45 alpha:1.0] set]; // .2 & .4 - [self.onString drawAtPoint:CGPointMake(onTextPoint.x, onTextPoint.y - 1.0) withFont:self.labelFont]; + [self.onString drawAtPoint:CGPointMake(onTextPoint.x, onTextPoint.y -1.0) withAttributes:@{NSFontAttributeName: self.labelFont}]; [[UIColor whiteColor] set]; - [self.onString drawAtPoint:onTextPoint withFont:self.labelFont]; - + [self.onString drawAtPoint:onTextPoint withAttributes:@{NSFontAttributeName: self.labelFont}]; // 'OFF' state label (self.offString) - CGSize offTextSize = [self.offString sizeWithFont:self.labelFont]; + CGSize offTextSize = [self.offString sizeWithAttributes:@{NSFontAttributeName: self.labelFont}]; + CGPoint offTextPoint = CGPointMake(textSpaceWidth + (textSpaceWidth - offTextSize.width) / 2.0 + knobRadius * .86, floorf((self.bounds.size.height - offTextSize.height) / 2.0) + 1.0); [[UIColor whiteColor] set]; - [self.offString drawAtPoint:CGPointMake(offTextPoint.x, offTextPoint.y + 1.0) withFont:self.labelFont]; - [[UIColor colorWithWhite:0.52 alpha:1.0] set]; - [self.offString drawAtPoint:offTextPoint withFont:self.labelFont]; - + [self.offString drawAtPoint:CGPointMake(offTextPoint.x, offTextPoint.y + 1.0) withAttributes:@{NSFontAttributeName: self.labelFont}]; + [[UIColor colorWithWhite:0.52 alpha:1.0] set]; + [self.offString drawAtPoint:offTextPoint withAttributes:@{NSFontAttributeName: self.labelFont}]; + UIGraphicsPopContext(); }