cut

CuteAttribute

An elegant way to deal with attributed string in swift.

Showing:

Popularity

Downloads/wk

0

GitHub Stars

64

Maintenance

Last Commit

2yrs ago

Contributors

2

Package

Dependencies

0

License

MIT

Categories

Readme

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 nameresultNSAttributedStringCuteAttribute
colorNSMutableAttributedString(string: "hello world", attributes: [.foregroundColor: UIColor.red])"hello world".cute.matchAll().color(.red)
baselineOffsetNSMutableAttributedString(string: "hello world", attributes: [.baselineOffset: 10])"hello world".cute.matchAll().baseline(10)
underlineNSMutableAttributedString(string: "hello world", attributes: [.underlineColor: UIColor.red, .underlineStyle: NSUnderlineStyle.styleSingle.rawValue])"hello world".cute.matchAll().underline(.styleSingle).underlineColor(.red)
fontNSMutableAttributedString(string: "hello world", attributes: [NSAttributedStringKey.font: UIFont.systemFont(ofSize: 20)])"hello world".cute.matchAll().font(UIFont.systemFont(ofSize: 20))
strikethroughNSMutableAttributedString(string: "hello world", attributes: [.strikethroughStyle: NSUnderlineStyle.styleSingle.rawValue, .strikethroughColor: UIColor.red])"hello world".cute.matchAll().strikeThrough(.styleSingle).strokeColor(.red)
linkNSMutableAttributedString(string: "hello world", attributes: [.link: "https://blog.vsccw.com"])"hello world".cute.matchAll().link("https://blog.vsccw.com")
ligatureNSMutableAttributedString(string: "hello world", attributes: [.ligature: 1])"hello world".cute.matchAll().ligature(1)
kernNSMutableAttributedString(string: "hello world", attributes: [.kern: 10])"hello world".cute.matchAll().kern(10)
strokeNSMutableAttributedString(string: "hello world", attributes: [.strokeColor: UIColor.red, .strokeWidth: 10])"hello world".cute.matchAll().strokeColor(.red).strokeWidth(10)
shadowlet 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)
textEffectno image"hello world".cute.matchAll().textEffect("NSTextEffectLetterpressStyle")"hello world".cute.matchAll().textEffect("NSTextEffectLetterpressStyle")
obliquenessNSMutableAttributedString(string: "hello world", attributes: [.obliqueness: 10])"hello world".cute.matchAll().obliqueness(10)
expansionNSMutableAttributedString(string: "hello world", attributes: [.expansion: 10])"hello world".cute.matchAll().expansion(10)
textAttachmentlet 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

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial