DLRUIKit
安装
DLRUIKit 可通过 CocoaPods 获得。要安装它,只需在您的 Podfile 中添加以下行:
pod "DLRUIKit"
作者
Nathan Walczak,[email protected]
许可协议
DLRUIKit 受 MIT 许可协议保护。更多详情请参阅 LICENSE 文件。
示例
UIButton 分类示例
正常状态 | 高亮状态 | 禁用状态 |
---|---|---|
UIButton dlr_setBackgroundColor: forState
[self.veryNiceButton dlr_setBackgroundColor:[UIColor brownColor] forState:UIControlStateNormal];
[self.veryNiceButton dlr_setBackgroundColor:[UIColor blueColor] forState:UIControlStateHighlighted];
[self.veryNiceButton dlr_setBackgroundColor:[UIColor lightGrayColor] forState:UIControlStateDisabled];
UIView dlr_applyRoundedCornersWithRadius
[self.veryNiceButton dlr_applyRoundedCornersWithRadius:18.0f];
UIColor 分类示例
UIColor dlr_colorWithRed: green: blue
self.navyBlueView.backgroundColor = [UIColor dlr_colorWithRed:25 green:116 blue:210];
self.outrageousOrangeView.backgroundColor = [UIColor dlr_colorWithRed:255 green:110 blue:74];
self.purpleHeartView.backgroundColor = [UIColor dlr_colorWithRed:116 green:66 blue:200];
self.tumbleweedView.backgroundColor = [UIColor dlr_colorWithRed:222 green:170 blue:136];
self.unmellowYellowView.backgroundColor = [UIColor dlr_colorWithRed:255 green:255 blue:102 alpha:0.6f];
UIView dlr_applyRoundedCornersWithRadius
[self.navyBlueView dlr_applyRoundedCornersWithRadius:18.0f];
[self.outrageousOrangeView dlr_applyRoundedCornersWithRadius:18.0f];
[self.purpleHeartView dlr_applyRoundedCornersWithRadius:18.0f];
[self.tumbleweedView dlr_applyRoundedCornersWithRadius:18.0f];
[self.unmellowYellowView dlr_applyRoundedCornersWithRadius:18.0f];
UIViewController+DLRParentViewController 分类示例
屏幕截图 | 故事板 |
---|---|
UIViewController dlr_instantiateViewController
ChildViewController *childViewController = [ChildViewController dlr_instantiateViewController];
UIViewController dlr_addToParentViewController
[childViewController dlr_addToParentViewController:self parentView:self.containerView];
UIView dlr_applyRoundedCornersWithRadius
[self.containerView dlr_applyRoundedCornersWithRadius:18.0f];
UIViewController+DLRStoryboardManager 分类示例
为每个故事板创建一个分类。
#import "DLRStoryboardManager+Main.h"
#import "ChildViewController.h"
static NSString * const kStoryboardName = @"Main"; // Main.storyboard
@implementation DLRStoryboardManager (Main)
+ (void)load {
[self registerStoryboardName:kStoryboardName
withStoryboardIdentifier:NSStringFromClass([ChildViewController class])];
}
@end
这些分类可以生成。
bin/DLRStoryboardManager.sh DLRUIKitExampleApp/Main.storyboard
让我们实例化一个子视图控制器。
ChildViewController *childViewController = [ChildViewController dlr_instantiateViewController];
UIDevice 类别示例
用户界面风格
/** Returns true if current device has an idiom of pad. */
+ (BOOL)dlr_isUserInterfaceIdiomPad;
系统版本
/** Returns true if the curent device system version is equal to version. */
+ (BOOL)dlr_isSystemVersionEqualToVersion:(NSString *)version;
/** Returns true if the curent device system version is greater than version. */
+ (BOOL)dlr_isSystemVersionGreaterThanVersion:(NSString *)version;
/** Returns true if the curent device system version is greater than or equal to version. */
+ (BOOL)dlr_isSystemVersionGreaterThanOrEqualToVersion:(NSString *)version;
/** Returns true if the curent device system version is less than version. */
+ (BOOL)dlr_isSystemVersionLessThanVersion:(NSString *)version;
/** Returns true if the curent device system version is less than or equal to version. */
+ (BOOL)dlr_isSystemVersionLessThanOrEqualToVersion:(NSString *)version;
DLRLayoutConstraint 示例
/** Resets the constant back to the initial value after awake from nib. */
- (void)dlr_applyInitialConstant;
@property (weak, nonatomic) IBOutlet DLRLayoutConstraint *layoutConstraint;
// initial value of layoutConstraint.constant is 50
layoutConstraint.constant = -10;
// resets layoutConstraint.constant back to 50
[layoutConstraint dlr_applyInitialConstant];
UINavigationController+DLR 类别示例
/** Returns true if the passed view controller is the first view controller in the
stack of view controllers. This can be helpful in determining if the
view controller needed to be popped or dismissed. */
- (BOOL)dlr_isFirstViewController:(UIViewController *)viewController;
UIViewController+DLRNavigationController 类别示例
/** Returns a new navigation controller instance with this view controller as the
root view controller. */
- (UINavigationController *)dlr_embedInsideNavigationController;
UIViewController+DLRPresentedViewController 类示例
/** Returns the top most presented view controller, which could be this view controller. */
- (UIViewController *)dlr_topPresentedViewController;