APExtensions 14.2.0

APExtensions 14.2.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Mar 2024
SPMSupports SPM

Maintained by Anton Plebanovich.



  • By
  • Anton Plebanovich

APExtensions

Carthage compatible Swift Package Manager 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

Swift Package Manager

  • In Xcode select File > Add Packages...
  • Copy and paste the following into the search: https://github.com/APUtils/APExtensions
  • ‼️Make sure Up to Next Major Version is selected and put 13.0.0 into the lower bound. There is a bug in Xcode, it does not select versions higher than 9.0.0 by default‼️
  • Tap Add Package
  • Select APExtension to add everything and tap Add Package

CocoaPods

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

pod 'APExtensions', '~> 13.0'

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

pod 'APExtensions/Core', '~> 13.0'
pod 'APExtensions/Storyboard', '~> 13.0'
pod 'APExtensions/ViewModel', '~> 13.0'

Carthage DEPRECATED

Please check official guide

Cartfile:

github "APUtils/APExtensions" "carthage-old"

Install command: carthage bootstrap

You should later add both APExtensions and RoutableLogger frameworks to your project.

Carthage with XCFrameworks DEPRECATED

Please check official guide

Cartfile:

github "APUtils/APExtensions" ~> 13.0

Install command: carthage bootstrap --use-xcframeworks

You should later add both APExtensions and RoutableLogger frameworks to your project.

Usage

See documentation for more details.

Core

Global Utils and Debug methods, Controllers, Protocols and whole lot of default classes extensions. Read more in DOCS.

ViewModel

Adds ViewModel struct and .configure(vm:) method to views so it's easy and robust to configure them.

ViewState

Moved to https://github.com/APUtils/ViewState

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.

Occupiable

Occupiable protocol

OptionalType

OptionalType protocol

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.