Skip to content

yim2627/StackyText

Repository files navigation

StackyText

StackyText supports textBlock like LEGO

Swift Package Manager compatible Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • iOS 13 higher
  • Swift 5.0 higher

Installation

CocoaPods

StackyText is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'StackyText'

Swift Package Manager

Enter StackyText URL in Package Dependency

https://github.com/yim2627/StackyText

Usage

First, Import the fonts you want to use into your project and Update plist

Make sure the fonts have been added

UIFont.checkFamilyFontName()

To support dynamic types

adjustsFontForContentSizeCategory = true

OR...

image

Normal Text

let label = UILabel()

label.adjustsFontForContentSizeCategory = true

label.text = "NotoSans_Black"
label.textColor = .black
label.font = .withFontFamilyName(name: "NotoSansKR", type: .black, dynamic: .title1)

// OR...

label.font = withFontName("NotoSansKR-Black", dynamic: .title1)

AttributedString Stacky Text

let label = UILabel()

label.adjustsFontForContentSizeCategory = true

stackLabel.textColor = .black
stackLabel.attributedText = NSMutableAttributedString()
     .text("Noto", fontName: "NotoSansKR", type: .black, dynamic: .title1)
     .text("Sans", fontName: "NotoSansKR", type: .thin, dynamic: .body)
     .colorText("K", fontName: "NotoSansKR", type: .bold, dynamic: .largeTitle, color: .systemBlue)
     .colorText("R", fontName: "NotoSansKR", type: .regular, dynamic: .largeTitle, color: .systemRed)

Simulator

Normal Dynamic Type

Author

Jiseong, [email protected]

License

StackyText is available under the MIT license. See the LICENSE file for more info.