Latest 4.1.1
Homepage https://github.com/APUtils/APExtensions
License MIT
Platforms ios 8.0
Frameworks Foundation, UIKit, MessageUI
Authors

Carthage compatible
Version
License
Platform
CI Status

A helpful collection of extensions, controllers and protocols

Example

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

Installation

Carthage

Please check official guide

Cartfile:

github "APUtils/APExtensions"

CocoaPods

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

pod 'APExtensions'

Available subspecs: Core, ViewState, Storyboard. Example Podfile for subspec:

pod 'APExtensions/Core'
pod 'APExtensions/ViewState'
pod 'APExtensions/Storyboard'

Usage

See documentation for more details.

Core

TODO

Abstractions

Various abstractions that simplyfies working.

DelayedValue

Simple abstraction that simplifies working with values that needs some time to be fetched. Kind of promise. Good to use in view models to simplify view configuration.

DelayedValue<UIImage> { completion in
    // Getting image async. It takes some time.

    // Return image
    completion(image)
}.onValueAvailable { image in
    // Will be called when image is available
    self.imageView.image = image
}

ViewConfiguration

Adds State enum and .configure(_:) method to views so it’s easy and robust to configure them.

// Creating UIImageView.State and store it in view model
let imageViewState: UIImageView.State = .shown(image: UIImage(named: "ic_done_resizeable"))
viewModel.imageViewState = imageViewState

// Configure UIImageView with view model
imageView.configure(viewModel.imageViewState)

ViewState

ViewController

  • Extends UIViewController with .viewState enum property. Possible cases: .notLoaded, .didLoad, .willAppear, .didAppear, .willDisappear, .didDisappear.
  • Every UIViewController starts to send notifications about its state change. Available notifications to observe: .UIViewControllerWillMoveToParentViewController, .UIViewControllerViewDidLoad, .UIViewControllerViewWillAppear, .UIViewControllerViewDidAppear, .UIViewControllerViewWillDisappear, .UIViewControllerViewDidDisappear. You could check userInfo notification’s dictionary for parameters if needed.
  • Adds .hideKeyboardOnTouch @IBInspectable property to hide keyboard on touch outside.

View

Adds .becomeFirstResponderOnViewDidAppear @IBInspectable property to become first responser on viewDidAppear.

Storyboard

Extends default attributes that can be configured using storyboard.

NSLayoutConstraint:

  • fitScreenSize to adjust constraint constant according to screen size. *
  • onePixelSize to make constraint 1 pixel size

UIButton:

  • fitScreenSize to adjust font size according to screen size. *
  • lines to change title label max lines count

UIImageView:

  • fitScreenSize to adjust image size according to screen size. *
  • localizableImageName to use localize specific image. You name your images like image_en, image_ru, image_fr put image in localizableImageName field and assure you localized _en to be _fr for French localization, _ru for Russian and so on.

UILabel:

  • fitScreenSize to adjust font size according to screen size. *

UIScrollView:

  • avoidTopBars to set contentInset.top to 64
  • avoidTabBar to set contentInset.bottom to 49

UITextView:

  • fitScreenSize to adjust font size according to screen size. *

UIView:

  • borderColor to set border color
  • borderWidth to set border width
  • borderOnePixelWidth to make border 1 pixel width
  • cornerRadius to set corners radius
  • shadowColor to set shadow color
  • shadowOffset to set shadow offset
  • shadowOpacity to set shadow opacity
  • shadowRadius to set shadow radius
  • shadowApplyPath to apply view bounds rect as shadow pass. Greatly improves performance for opaque views.

UIViewController:

  • hideKeyboardOnTouch to hide keyboard on touch outside it

Remark

Assuming layout was made for highest screen size (iPhone 6+, 6s+, 7+) so subject will be reduced propotionally on lower resolution screens.

Contributions

Any contribution is more than welcome! You can contribute through pull requests and issues on GitHub.

Author

Anton Plebanovich, [email protected]

License

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

Latest podspec

{
    "name": "APExtensions",
    "version": "4.1.1",
    "summary": "A helpful collection of extensions, controllers and protocols.",
    "description": "A helpful collection of extensions, controllers and protocols. See documentation for details.",
    "homepage": "https://github.com/APUtils/APExtensions",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Anton Plebanovich": "[email protected]"
    },
    "source": {
        "git": "https://github.com/APUtils/APExtensions.git",
        "tag": "4.1.1"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "APExtensions/Classes/**/*",
    "private_header_files": "APExtensions/Classes/ViewState/ViewStateLoader.h",
    "frameworks": [
        "Foundation",
        "UIKit",
        "MessageUI"
    ],
    "pushed_with_swift_version": "4.0",
    "subspecs": [
        {
            "name": "Core",
            "source_files": "APExtensions/Classes/Core/**/*"
        },
        {
            "name": "Abstractions",
            "source_files": "APExtensions/Classes/Abstractions/**/*"
        },
        {
            "name": "ViewState",
            "source_files": "APExtensions/Classes/ViewState/**/*",
            "private_header_files": "APExtensions/Classes/ViewState/ViewStateLoader.h"
        },
        {
            "name": "Storyboard",
            "source_files": "APExtensions/Classes/Storyboard/**/*"
        }
    ]
}

Pin It on Pinterest

Share This