Skip to content

Commit

Permalink
Swift 4 migration
Browse files Browse the repository at this point in the history
  • Loading branch information
loregr committed Oct 11, 2017
1 parent e6c1d74 commit 827245c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 25 deletions.
8 changes: 5 additions & 3 deletions Example/LGButton.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
TargetAttributes = {
607FACCF1AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
LastSwiftMigration = 0820;
LastSwiftMigration = 0900;
};
};
};
Expand Down Expand Up @@ -359,7 +359,8 @@
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -374,7 +375,8 @@
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down
Binary file not shown.
40 changes: 21 additions & 19 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion LGButton/Classes/SwiftIconFont/FontLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class FontLoader: NSObject {
let font = CGFont.init(provider!)

var error: Unmanaged<CFError>?
if !CTFontManagerRegisterGraphicsFont(font, &error) {
if !CTFontManagerRegisterGraphicsFont(font!, &error) {
let errorDescription: CFString = CFErrorCopyDescription(error!.takeUnretainedValue())
let nsError = error!.takeUnretainedValue() as AnyObject as! NSError
NSException(name: NSExceptionName.internalInconsistencyException, reason: errorDescription as String, userInfo: [NSUnderlyingErrorKey: nsError]).raise()
Expand Down
4 changes: 2 additions & 2 deletions LGButton/Classes/SwiftIconFont/SwiftIconFont.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public extension UIImage
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.alignment = NSTextAlignment.center

drawText!.draw(in: CGRect(x:0, y:0, width:imageSize.width, height:imageSize.height), withAttributes: [NSFontAttributeName : UIFont.icon(from: font, ofSize: size), NSParagraphStyleAttributeName: paragraphStyle, NSForegroundColorAttributeName: iconColor])
drawText!.draw(in: CGRect(x:0, y:0, width:imageSize.width, height:imageSize.height), withAttributes: [NSAttributedStringKey.font : UIFont.icon(from: font, ofSize: size), NSAttributedStringKey.paragraphStyle: paragraphStyle, NSAttributedStringKey.foregroundColor: iconColor])

let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
Expand Down Expand Up @@ -204,7 +204,7 @@ func getAttributedString(_ text: NSString, ofSize size: CGFloat) -> NSMutableAtt
if let _ = fontArr[fontCode] {
attributedString.replaceCharacters(in: substringRange, with: String.getIcon(from: fontType, code: fontCode)!)
let newRange = NSRange(location: substringRange.location, length: 1)
attributedString.addAttribute(NSFontAttributeName, value: UIFont.icon(from: fontType, ofSize: size), range: newRange)
attributedString.addAttribute(NSAttributedStringKey.font, value: UIFont.icon(from: fontType, ofSize: size), range: newRange)
}
}

Expand Down

0 comments on commit 827245c

Please sign in to comment.