Skip to content

Commit

Permalink
set line spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
bhlvoong committed Nov 29, 2016
1 parent c0f09cc commit f5aa825
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
9 changes: 8 additions & 1 deletion Example/LBTAComponents.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0720;
LastUpgradeCheck = 0810;
ORGANIZATIONNAME = CocoaPods;
TargetAttributes = {
607FACCF1AFB9204008FA782 = {
Expand Down Expand Up @@ -460,8 +460,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand Down Expand Up @@ -505,8 +507,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand All @@ -525,6 +529,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand All @@ -533,6 +538,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 90459509810B85F0D6CAB502 /* Pods-LBTAComponents_Example.debug.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = 4HZZVGNXGK;
INFOPLIST_FILE = LBTAComponents/Info.plist;
Expand All @@ -549,6 +555,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 2E02ED6FDB12A1A9493596B5 /* Pods-LBTAComponents_Example.release.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = 4HZZVGNXGK;
INFOPLIST_FILE = LBTAComponents/Info.plist;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
LastUpgradeVersion = "0810"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
11 changes: 10 additions & 1 deletion LBTAComponents/Classes/NSMutableAttributedString+Helper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,16 @@ extension NSMutableAttributedString {
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.alignment = .center
paragraphStyle.lineSpacing = lineSpacing

setParagraphStyle(paragraphStyle: paragraphStyle)
}

public func setLineSpacing(_ lineSpacing: CGFloat) {
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = lineSpacing
setParagraphStyle(paragraphStyle: paragraphStyle)
}

func setParagraphStyle(paragraphStyle: NSParagraphStyle) {
let range = NSMakeRange(0, string.characters.count)
addAttribute(NSParagraphStyleAttributeName, value: paragraphStyle, range: range)
}
Expand Down

0 comments on commit f5aa825

Please sign in to comment.