Latest 1.0.2
Homepage https://github.com/cocoZ/KKInitializer
License MIT
Platforms ios 8.0, requires ARC
Authors

KKInitializer KKInitializer

常用UI控件的便利构造方法集合
现支持 UILabel/UIButton/UIImage/UITextField/UITextView/UIColor等

代码示例

    UILabel *label =  [UILabel k_labelWithText:@"Label构造器" boldFontSize:15 textColor:UIColor.redColor];
    label.k_cornerRadius(5).k_backgroudColor(UIColor.lightGrayColor).k_frame(CGRectMake(100, 100, 100, 40));
    [self.view addSubview:label];
    UIButton *btn = [UIButton k_btnForCustomTypeWithTitle:@"Button构造器" titleColor:[UIColor whiteColor] fontSize:20];
    btn.k_bgImgColor([UIColor purpleColor]).k_cornerRadius(5.0f);
    [self.view addSubview:btn.k_frame(CGRectMake(100, 200, 150, 40))];
    UIImage *img = UIImage.k_imgFillColor(UIColor.redColor, CGSizeMake(100, 100)).k_cornerRadius(5.0f);
    UIImageView *imgView = [[UIImageView alloc] initWithImage:img];
    imgView.frame = CGRectMake(100, 400, 100, 100);
    [self.view addSubview:imgView];
    UITextField *textField = UITextField.k_initFrame(CGRectMake(100, 100, 200, 40));
    textField.k_placeholder(@"占位占位占位").k_borderStyle(UITextBorderStyleRoundedRect).k_textColor(UIColor.redColor).k_fontSize(20.f);
    [self.view addSubview:textField];
    UITextView *textView = UITextView.k_init().k_textColor(UIColor.redColor).k_boldFontSize(15.f);
    [self.view addSubview:textView];
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
    view.backgroundColor = UIColor.k_hexColor(0xFF3300);
    view.backgroundColor = UIColor.k_RGBColor(255,121,0);
    view.backgroundColor = UIColor.k_randomColor();
    [self.view addSubview:view];

Cocoapods

全部控件构造方法扩展(推荐):

pod 'KKInitializer'

需要其中1个或多个 ,选择使用:

pod 'KKInitializer/UILabel+KKInitializer'
pod 'KKInitializer/UIButton+KKInitializer'
pod 'KKInitializer/UIImage+KKInitializer'
pod 'KKInitializer/UITextField+KKInitializer'
pod 'KKInitializer/UITextView+KKInitializer'
pod 'KKInitializer/UIColor+KKInitializer'

blog

简书:https://www.jianshu.com/p/e6ef1df5dd9a

Latest podspec

{
    "name": "KKInitializer",
    "version": "1.0.2",
    "summary": "u94feu5f0fu8bedu6cd5u5f0fu57fau7840u63a7u4ef6u7684u4fbfu5229u6784u9020u5668uff0cu5305u542bUILabelu3001UIButtonu3001UIImageu3001UITextFieldu3001UITextViewu3001UIColoru7b49",
    "homepage": "https://github.com/cocoZ/KKInitializer",
    "license": "MIT",
    "authors": {
        "cocoa": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source": {
        "git": "https://github.com/cocoZ/KKInitializer.git",
        "tag": "1.0.2"
    },
    "source_files": [
        "Initializer",
        "Initializer/KKInitializer.h"
    ],
    "public_header_files": "Initializer/KKInitializer.h",
    "subspecs": [
        {
            "name": "UILabel+KKInitializer",
            "source_files": [
                "UILabel",
                "UILabel/*.{h,m}"
            ]
        },
        {
            "name": "UIButton+KKInitializer",
            "source_files": [
                "UIButton",
                "UIButton/*.{h,m}"
            ]
        },
        {
            "name": "UIImage+KKInitializer",
            "source_files": [
                "UIImage",
                "UIImage/*.{h,m}"
            ]
        },
        {
            "name": "UITextField+KKInitializer",
            "source_files": [
                "UITextField",
                "UITextField/*.{h,m}"
            ],
            "dependencies": {
                "KKInitializer/UIButton+KKInitializer": []
            }
        },
        {
            "name": "UITextView+KKInitializer",
            "source_files": [
                "UITextView",
                "UITextView/*.{h,m}"
            ]
        },
        {
            "name": "UIColor+KKInitializer",
            "source_files": [
                "UIColor",
                "UIColor/*.{h,m}"
            ]
        }
    ]
}

Pin It on Pinterest

Share This