All Projects → dimpiax → Styledecorator

dimpiax / Styledecorator

Licence: mit
Easy string decoration with styles

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Styledecorator

Mscircularslider
A fully-featured, powerful circular slider for iOS applications
Stars: ✭ 94 (+452.94%)
Mutual labels:  library, cocoapods
Campcotcollectionview
Collapse and expand UICollectionView sections with one method call.
Stars: ✭ 161 (+847.06%)
Mutual labels:  library, cocoapods
Predicateflow
Write amazing, strong-typed and easy-to-read NSPredicate.
Stars: ✭ 98 (+476.47%)
Mutual labels:  library, cocoapods
Imageviewer.swift
An easy to use Image Viewer that is inspired by Facebook
Stars: ✭ 1,071 (+6200%)
Mutual labels:  library, cocoapods
Greedo Layout For Ios
Full aspect ratio grid layout for iOS
Stars: ✭ 837 (+4823.53%)
Mutual labels:  library, cocoapods
Loadingshimmer
An easy way to add a shimmering effect to any view with just one line of code. It is useful as an unobtrusive loading indicator.
Stars: ✭ 1,180 (+6841.18%)
Mutual labels:  library, cocoapods
Fscalendar
A fully customizable iOS calendar library, compatible with Objective-C and Swift
Stars: ✭ 9,829 (+57717.65%)
Mutual labels:  library, cocoapods
Keyboardhidemanager
Codeless manager to hide keyboard by tapping on views for iOS written in Swift
Stars: ✭ 57 (+235.29%)
Mutual labels:  library, cocoapods
Observable
The easiest way to observe values in Swift.
Stars: ✭ 346 (+1935.29%)
Mutual labels:  library, cocoapods
Slidecontroller
Swipe between pages with an interactive title navigation control. Configure horizontal or vertical chains for unlimited pages amount.
Stars: ✭ 279 (+1541.18%)
Mutual labels:  library, cocoapods
Datepicker
A Date Picker with Calendar for iPhone and iPad Apps.
Stars: ✭ 103 (+505.88%)
Mutual labels:  library, cocoapods
Tsmessages
💌 Easy to use and customizable messages/notifications for iOS à la Tweetbot
Stars: ✭ 4,927 (+28882.35%)
Mutual labels:  library, cocoapods
Alertift
Swifty, modern UIAlertController wrapper.
Stars: ✭ 242 (+1323.53%)
Mutual labels:  library, cocoapods
Shadowview
An iOS Library that makes shadows management easy on UIView.
Stars: ✭ 391 (+2200%)
Mutual labels:  library, cocoapods
Leetheme
优雅的主题管理库- 一行代码完成多样式切换
Stars: ✭ 762 (+4382.35%)
Mutual labels:  cocoapods, style
System.js
The library System.js designed to improve the quality of writing JavaScript source code. It contains features that allow you refactor source code. Thanks to the clear and readable functions, the code will be good understood and supported accordingly.
Stars: ✭ 6 (-64.71%)
Mutual labels:  library
Elongation Preview
ElongationPreview is an elegant UI push-pop style view controller. iOS library made by @Ramotion
Stars: ✭ 888 (+5123.53%)
Mutual labels:  library
Experiment
🔬 Elixir Library for carefully refactoring critical paths by performing experiments.
Stars: ✭ 6 (-64.71%)
Mutual labels:  library
Tfidf
Simple TF IDF Library
Stars: ✭ 6 (-64.71%)
Mutual labels:  library
Webhere
HTML scraping for Objective-C.
Stars: ✭ 16 (-5.88%)
Mutual labels:  cocoapods

StyleDecorator

Language Version License Platform

Design string simply by linking attributes.

Example

Create Decorator with specific Style and link it at the end of needed string or wrap for styling:

"Style" + d1 + "Decorator" + d2 + "!"
// or
d1.wrap("Style") + d2.wrap("Decorator") + "!"

Example:

let a = Decorator(style: Style().foregroundColor(.black).kerning(-0.5).backgroundColor(.darkGray))
let b = Decorator(style: Style().foregroundColor(.white).backgroundColor(.black))
let c = Decorator(style: Style().foregroundColor(.gray).alignment(.right))

// You can write in syntax you prefer
let decoratedText = "Bold" + a + "Heavy" + b + "Black" + c
label.attributedText = NSAttributedString(decorator: decoratedText)

// or
let a1 = a.wrap, b1 = b.wrap, c1 = c.wrap
let decoratedText2 = a1("Bold") + b1("Heavy") + c1("Black")
label.attributedText = NSAttributedString(decorator: decoratedText2)

String can be designed dynamically:

// check Example for detailed code, where created 'd', 'e', 'f' etc

let titleText = "! " + ("Bold" + b + "Heavy" + c + "Black" + d)
let decoratedText = "Decorate attributed string simply" + a + "\n\n" + titleText + "\n\n" + "Right" + e + "\n" + "below black rect with red line" + f + "\n\n\nwith default attributes"

let defaultAttributes = Style()
    .font(UIFont.systemFont(ofSize: 15, weight: UIFontWeightBlack))
    .alignment(.center)
    .attributes

label.attributedText = NSAttributedString(decorator: decoratedText, attributes: defaultAttributes)

Requirements

Updated to Swift 5

Supports SPM

For Swift 4 version use v.0.4.2
For Swift 3.1 version use v.0.3.0

Installation

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

pod "StyleDecorator"

Author

Dmytro Pylypenko, [email protected]

License

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

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].