Dima Pilipenko

6pods

AttributedStyle

AttributedStyle

Swifty adaptation of NSAttributedStyle and NSParagraphStyle

  • easy setup and reusing
  • almost each attribute as function
  • compact view

```swift let attributedStyle = AttributedStyle().font(UIFont.systemFont(ofSize: 21, weight: UIFontWeightLight)) let parapraphStyle = ParagraphStyle().lineBreakMode(.byTruncatingMiddle) let attributes = attributedStyle.paragraphStyle(parapraphStyle.style).foregroundColor(.gray).attributes

let label = UILabel() label.attributedText = NSAttributedString(string: "Attribute it!", attributes: attributes) // or label.attributedText = NSAttributedString(string: "Attribute it!", attributes: AttributedStyle().font(UIFont.systemFont(ofSize: 21, weight: UIFontWeightLight)).foregroundColor(UIColor.darkGray).paragraphStyle(ParagraphStyle().alignment(.center).style).attributes) ```

License: MIT

  • Swift

FlexibleCollectionViewController

Swift library of generic collection view controller with external data processing of functionality, like determine cell's reuseIdentifier related to indexPath, configuration of requested cell for display and cell selection handler etc

License: MIT

  • Swift

FlexibleTableViewController

Generic table view controller with external data processing of functionality, like determine cell's reuseIdentifier related to indexPath, configuration of requested cell for display and cell selection handler

License: MIT

  • Swift

RichTimer

RichTimer – it's easy NSTimer managment and compact visual appearance. Accepts generic parameters for common functions

License: MIT

  • Swift

StyleDecorator

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

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

Example: ```swift let a = Decorator(style: Style().foregroundColor(.black).kerning(-0.5).backgroundColor(.darkGray)) let b = Decorator(style: Style().foregroundColor(.white)) 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: ```swift // 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 + "

" + titleText + "

" + "Right" + e + " " + "below black rect with red line" + f + "

with default attributes"

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

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

License: MIT

  • Swift

WizardViewController

Build your tutorial / description / informative screens by trivial approach. Setup visual assets and be flexible with page delegation. Put special views or controls on top subview, which is not scrolling.

```swift _wizardVC = WizardViewController() _wizardVC.modalTransitionStyle = .coverVertical _wizardVC.modalPresentationStyle = .overCurrentContext

// setup page indicators _wizardVC.pageIndicatorColors = {[unowned self] currentPageIndex in let value: UIColor

if let color = self._wizardVC.getView(index: currentPageIndex)?.backgroundColor {
    var r: CGFloat = 0, g: CGFloat = 0, b: CGFloat = 0, a: CGFloat = 0
    color.getRed(&r, green: &g, blue: &b, alpha: &a)

    // inverse color
    value = UIColor(red: 1-r, green: 1-g, blue: 1-b, alpha: 1)
}
else {
    switch currentPageIndex {
        case 1: value = .darkGray
        case 2: value = .gray
        default: value = .black
    }

}

return (nil, value)

}

// set views _wizardVC.setViews([B(), B(), B()])

// or

// set view controllers _wizardVC.setViewControllers([A(), A(), A(), A()])

// set custom view on top subview let button = UIButton(type: .custom) button.setTitle("skip", for: .normal) button.sizeToFit() button.frame.origin.y = view.bounds.height - button.bounds.height - 50 button.frame.size.width = view.bounds.width button.addTarget(self, action: #selector(closeTutorial), for: .touchUpInside)

_wizardVC.setTop(view: button) ```

License: MIT

  • Swift