-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
2,036 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// | ||
// Created by Jan Kase on 10/04/2018. | ||
// Copyright (c) 2018 Jan Kase. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
public struct JKStringAttributes { | ||
|
||
public var font: UIFont? | ||
public var fontColor: UIColor? | ||
|
||
public var baseLineOffset: CGFloat? | ||
|
||
public var backgroundColor: UIColor? | ||
|
||
public var paragraphStyle: NSParagraphStyle? | ||
|
||
public var strikeThroughStyle: NSUnderlineStyle? | ||
public var strokeColor: UIColor? | ||
public var strokeWidth: CGFloat? | ||
public var underlineStyle: NSUnderlineStyle? | ||
public var underlineColor: UIColor? | ||
|
||
#if !os(watchOS) | ||
public var shadow: NSShadow? | ||
#endif | ||
#if swift(>=4) | ||
public var attributes: [NSAttributedStringKey: Any] { | ||
var theCurrentAttributes: [NSAttributedStringKey: Any] = [:] | ||
|
||
theCurrentAttributes[.font] = font | ||
theCurrentAttributes[.foregroundColor] = fontColor | ||
|
||
theCurrentAttributes[.baselineOffset] = baseLineOffset | ||
|
||
theCurrentAttributes[.backgroundColor] = backgroundColor | ||
|
||
theCurrentAttributes[.paragraphStyle] = paragraphStyle | ||
|
||
theCurrentAttributes[.strikethroughStyle] = strikeThroughStyle?.rawValue | ||
theCurrentAttributes[.strokeColor] = strokeColor | ||
theCurrentAttributes[.strokeWidth] = strokeWidth | ||
theCurrentAttributes[.underlineStyle] = underlineStyle | ||
theCurrentAttributes[.underlineStyle] = underlineColor | ||
|
||
#if !os(watchOS) | ||
theCurrentAttributes[.shadow] = shadow | ||
#endif | ||
|
||
return theCurrentAttributes | ||
} | ||
#else | ||
|
||
public var attributes:[String:Any] { | ||
var theCurrentAttributes:[String:Any] = [:] | ||
|
||
theCurrentAttributes[NSFontAttributeName] = font | ||
theCurrentAttributes[NSForegroundColorAttributeName] = fontColor | ||
|
||
theCurrentAttributes[NSBaselineOffsetAttributeName] = baseLineOffset | ||
|
||
theCurrentAttributes[NSBackgroundColorAttributeName] = backgroundColor | ||
|
||
theCurrentAttributes[NSParagraphStyleAttributeName] = paragraphStyle | ||
|
||
theCurrentAttributes[NSStrikethroughStyleAttributeName] = strikeThroughStyle?.rawValue | ||
theCurrentAttributes[NSStrokeColorAttributeName] = strokeColor | ||
theCurrentAttributes[NSStrokeWidthAttributeName] = strokeWidth | ||
theCurrentAttributes[NSUnderlineStyleAttributeName] = underlineStyle | ||
theCurrentAttributes[NSUnderlineColorAttributeName] = underlineColor | ||
|
||
#if !os(watchOS) | ||
theCurrentAttributes[NSShadowAttributeName] = shadow | ||
#endif | ||
|
||
return theCurrentAttributes | ||
} | ||
#endif | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// Created by Jan Kase on 10/04/2018. | ||
// Copyright (c) 2018 Jan Kase. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
extension NSAttributedString { | ||
|
||
public convenience init(string aString: String, attributes anAttributes: JKStringAttributes) { | ||
self.init(string: aString, attributes: anAttributes.attributes) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>$(DEVELOPMENT_LANGUAGE)</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>FMWK</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleVersion</key> | ||
<string>$(CURRENT_PROJECT_VERSION)</string> | ||
<key>NSPrincipalClass</key> | ||
<string></string> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// JKStringAttribbutes_watchOS.h | ||
// JKStringAttribbutes_watchOS | ||
// | ||
// Created by Jan Kase on 10/04/2018. | ||
// Copyright © 2018 Jan Kase. All rights reserved. | ||
// | ||
|
||
#import <WatchKit/WatchKit.h> | ||
|
||
//! Project version number for JKStringAttribbutes_watchOS. | ||
FOUNDATION_EXPORT double JKStringAttribbutes_watchOSVersionNumber; | ||
|
||
//! Project version string for JKStringAttribbutes_watchOS. | ||
FOUNDATION_EXPORT const unsigned char JKStringAttribbutes_watchOSVersionString[]; | ||
|
||
// In this header, you should import all the public headers of your framework using statements like #import <JKStringAttribbutes_watchOS/PublicHeader.h> | ||
|
||
|
Oops, something went wrong.