A helpful collection of extensions, controllers and protocols
To run the example project, clone the repo, and run pod install from the Example directory first.
- In Xcode select
File>Add Packages... - Copy and paste the following into the search:
https://github.com/APUtils/APExtensions ‼️ Make sureUp to Next Major Versionis selected and put15.0.0into 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
APExtensionto add everything and tapAdd Package
APExtensions is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'APExtensions', '~> 15.0'Available subspecs: Core, Storyboard, ViewModel. Example Podfile for subspec:
pod 'APExtensions/Core', '~> 15.0'
pod 'APExtensions/Storyboard', '~> 15.0'
pod 'APExtensions/ViewModel', '~> 15.0'See documentation for more details.
Global Utils and Debug methods, Controllers, Protocols and whole lot of default classes extensions. Read more in DOCS.
Adds ViewModel struct and .configure(vm:) method to views so it's easy and robust to configure them.
Moved to https://github.com/APUtils/ViewState
Extends default attributes that can be configured using storyboard.
NSLayoutConstraint:
fitScreenSizeto adjust constraint constant according to screen size. *onePixelSizeto make constraint 1 pixel size
UIButton:
fitScreenSizeto adjust font size according to screen size. *linesto change title label max lines count
UIImageView:
fitScreenSizeto adjust image size according to screen size. *localizableImageNameto use localize specific image. You name your images likeimage_en,image_ru,image_frputimageinlocalizableImageNamefield and assure you localized_ento be_frfor French localization,_rufor Russian and so on.
UILabel:
fitScreenSizeto adjust font size according to screen size. *
UIScrollView:
avoidTopBarsto set contentInset.top to 64avoidTabBarto set contentInset.bottom to 49
UITextView:
fitScreenSizeto adjust font size according to screen size. *
UIView:
borderColorto set border colorborderWidthto set border widthborderOnePixelWidthto make border 1 pixel widthcornerRadiusto set corners radiusshadowColorto set shadow colorshadowOffsetto set shadow offsetshadowOpacityto set shadow opacityshadowRadiusto set shadow radiusshadowApplyPathto apply view bounds rect as shadow pass. Greatly improves performance for opaque views.
UIViewController:
hideKeyboardOnTouchto hide keyboard on touch outside it
Assuming layout was made for highest screen size (iPhone 6+, 6s+, 7+) so subject will be reduced propotionally on lower resolution screens.
Occupiable protocol
OptionalType protocol
Any contribution is more than welcome! You can contribute through pull requests and issues on GitHub.
Anton Plebanovich, anton.plebanovich@gmail.com
APExtensions is available under the MIT license. See the LICENSE file for more info.







