All Projects → qiuncheng → CuteAttribute

qiuncheng / CuteAttribute

Licence: MIT license
An elegant way to deal with attributed string in swift.

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language
objective c
16641 projects - #2 most used programming language

Projects that are alternatives of or similar to CuteAttribute

AttributedStringWrapper
a simple packaging for NSAttributedString to make the developers easy to use
Stars: ✭ 16 (-75.38%)
Mutual labels:  nsattributedstring, nsmutableattributedstring
Swiftrichstring
👩‍🎨 Elegant Attributed String composition in Swift sauce
Stars: ✭ 2,744 (+4121.54%)
Mutual labels:  attributedstring, nsattributedstring
Typeset
Deal with AttributedString efficiently
Stars: ✭ 458 (+604.62%)
Mutual labels:  nsattributedstring
TypedTextAttributes
🖍 The Library Creating Text Attributes with Type-Safety
Stars: ✭ 55 (-15.38%)
Mutual labels:  nsattributedstring
Bostring
Create NSAttributedString like a boss!
Stars: ✭ 193 (+196.92%)
Mutual labels:  nsattributedstring
Atributika
Convert text with HTML tags, links, hashtags, mentions into NSAttributedString. Make them clickable with UILabel drop-in replacement.
Stars: ✭ 845 (+1200%)
Mutual labels:  nsattributedstring
Swiftuix
Extensions and additions to the standard SwiftUI library.
Stars: ✭ 4,087 (+6187.69%)
Mutual labels:  attributedstring
Commonmarkattributedstring
Create NSAttributedStrings from Markdown Text
Stars: ✭ 382 (+487.69%)
Mutual labels:  nsattributedstring
YBAttributeString
用Masonry的语法写NSAttributedString/a fast way to create attributedString like Masonry
Stars: ✭ 15 (-76.92%)
Mutual labels:  attributedstring
Cjlabel
A drop-in replacement for UILabel that supports NSAttributedString, rich text, display any view, links, select copy and more
Stars: ✭ 140 (+115.38%)
Mutual labels:  nsattributedstring
StringStylizer
Type strict builder class for NSAttributedString.
Stars: ✭ 75 (+15.38%)
Mutual labels:  nsattributedstring
Swiftyattributes
A Swifty API for attributed strings
Stars: ✭ 1,303 (+1904.62%)
Mutual labels:  nsattributedstring
Gaudi
A swift theming framework for UIKit for easy adoption of multi theme and iOS dark mode
Stars: ✭ 36 (-44.62%)
Mutual labels:  nsattributedstring
Nsattributedstringbuilder
Composing NSAttributedString with SwiftUI-style syntax
Stars: ✭ 660 (+915.38%)
Mutual labels:  nsattributedstring
RZColorful
NSAttributedString富文本的方法集合,以及简单优雅的使用其多种属性
Stars: ✭ 53 (-18.46%)
Mutual labels:  nsattributedstring
Nudein
An easy-to-use attributed text view for iOS Apps,use like masonry
Stars: ✭ 450 (+592.31%)
Mutual labels:  nsattributedstring
RichText
Easily show RichText(html) in SwiftUI
Stars: ✭ 25 (-61.54%)
Mutual labels:  attributedstring
Prestyler
Elegant text formatting tool in Swift 🔥
Stars: ✭ 36 (-44.62%)
Mutual labels:  nsattributedstring
AttributedStringBuilder
Easily construct attributed strings in swift
Stars: ✭ 69 (+6.15%)
Mutual labels:  nsattributedstring
Styledtextkit
Declarative building and fast rendering attributed string library.
Stars: ✭ 1,171 (+1701.54%)
Mutual labels:  nsattributedstring

CuteAttribute

Build Status Carthage compatible pod version GitHub license

An elegant way to deal with attributed string in swift. It's convenient to create attributed string by .cute, whatever from String, NSString, NSAttributedString or NSMutableAttributedString. It's so amazing that almost all methods support chaining. I create this project just because I met Typeset serveral days ago. But I found it's so hard to use by swift. So I made this.

Support

Swift 3.0 & iOS 8+

Installation

Swift Package Manager

  • add it to your Xcode project.
  • Import the header file in your project.
import CuteAttribute

CocoaPods

  • add it to your Podfile.
pod 'CuteAttribute'
  • Then run the command.
pod install
  • Import the header file in your project.
import CuteAttribute

Carthage

  • Add CuteAttribute to your Cartfile.
github "qiuncheng/CuteAttribute"
  • Run the command
carthage update --platform ios
import CuteAttribute

Manually

  • Download the full file.
  • Drag the CuteAttribute folder to your project.

Usage

Comparison

attribute name result NSAttributedString CuteAttribute
color NSMutableAttributedString(string: "hello world", attributes: [.foregroundColor: UIColor.red]) "hello world".cute.matchAll().color(.red)
baselineOffset NSMutableAttributedString(string: "hello world", attributes: [.baselineOffset: 10]) "hello world".cute.matchAll().baseline(10)
underline NSMutableAttributedString(string: "hello world", attributes: [.underlineColor: UIColor.red, .underlineStyle: NSUnderlineStyle.styleSingle.rawValue]) "hello world".cute.matchAll().underline(.styleSingle).underlineColor(.red)
font NSMutableAttributedString(string: "hello world", attributes: [NSAttributedStringKey.font: UIFont.systemFont(ofSize: 20)]) "hello world".cute.matchAll().font(UIFont.systemFont(ofSize: 20))
strikethrough NSMutableAttributedString(string: "hello world", attributes: [.strikethroughStyle: NSUnderlineStyle.styleSingle.rawValue, .strikethroughColor: UIColor.red]) "hello world".cute.matchAll().strikeThrough(.styleSingle).strokeColor(.red)
link NSMutableAttributedString(string: "hello world", attributes: [.link: "https://blog.vsccw.com"]) "hello world".cute.matchAll().link("https://blog.vsccw.com")
ligature NSMutableAttributedString(string: "hello world", attributes: [.ligature: 1]) "hello world".cute.matchAll().ligature(1)
kern NSMutableAttributedString(string: "hello world", attributes: [.kern: 10]) "hello world".cute.matchAll().kern(10)
stroke NSMutableAttributedString(string: "hello world", attributes: [.strokeColor: UIColor.red, .strokeWidth: 10]) "hello world".cute.matchAll().strokeColor(.red).strokeWidth(10)
shadow let shadow = NSShadow(); shadow.shadowColor = UIColor.red; shadow.shadowOffset = CGSize(width: 4, height: 4); shadow.shadowBlurRadius = 10; NSMutableAttributedString(string: "hello world", attributes: [.shadow: shadow]) "hello world".cute.matchAll().shadow(shadow)
textEffect no image "hello world".cute.matchAll().textEffect("NSTextEffectLetterpressStyle") "hello world".cute.matchAll().textEffect("NSTextEffectLetterpressStyle")
obliqueness NSMutableAttributedString(string: "hello world", attributes: [.obliqueness: 10]) "hello world".cute.matchAll().obliqueness(10)
expansion NSMutableAttributedString(string: "hello world", attributes: [.expansion: 10]) "hello world".cute.matchAll().expansion(10)
textAttachment let attachment = NSTextAttachment(); attachment.image = UIImage(named: "hello.png"); NSMutableAttributedString(string: "hello world", attributes: [.attachment: attachment]) "hello world".cute.matchAll().textAttachment(attachment)

TODO

  • Documented.
  • Example.
  • Test.
  • More convenience.

Thanks

Typeset : Deal with AttributedString efficiently in Objective-C.

LICENCE

Under MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].