EPSUIFactory is a class which provides factory methods for common configurations of UIKit controls. Some examples are:
UILabelUITextFieldset up for email entryUITextFieldset up for password entryUIViewset up to be used as the container view in aUIScrollViewwhich should only scroll vertically
All views returned by EPSUIFactory are ready to be used with auto layout (ie. they have translatesAutoresizingMaskIntoConstraints set to NO.)
- (void)viewDidLoad {
[super viewDidLoad];
UITextField *passwordField = [EPSUIFactory passwordTextField];
[self.view addSubview:passwordField];
// Add some constraints on `passwordField`
...
}For complete documentation of the methods available, see EPSUIFactory.h.
There is an included category on UIView which makes setup for views not included in the factory methods easier. Use eps_initForAutoLayout instead of initWithFrame: when you are creating a view for use with auto layout. For example:
UIView *view = [[UIView alloc] eps_initForAutoLayout];is equivalent to
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
view.translatesAutoresizingMaskIntoConstraints = NO;To run the example project; clone the repo, and run pod install from the “Project” directory first.
EPSUIFactory is available through CocoaPods, to install it simply add the following line to your Podfile:
pod "EPSUIFactory"Alternatively, add all files from the “Classes” folder to your project.
EPSUIFactory is available under the MIT license. See the LICENSE file for more info.