Skip to content

Commit

Permalink
initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
jankase committed Apr 10, 2018
1 parent 7020261 commit 25f5de0
Show file tree
Hide file tree
Showing 23 changed files with 2,036 additions and 0 deletions.
81 changes: 81 additions & 0 deletions Common/JKStringAttributes.swift
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

}
14 changes: 14 additions & 0 deletions Common/NSAttributedString+StringAttributes.swift
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)
}

}
24 changes: 24 additions & 0 deletions JKStringAttribbutes_watchOS/Info.plist
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>
19 changes: 19 additions & 0 deletions JKStringAttribbutes_watchOS/JKStringAttribbutes_watchOS.h
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>


Loading

0 comments on commit 25f5de0

Please sign in to comment.