Giter VIP home page Giter VIP logo

kmuimaker's Introduction

KMUIMaker

使用类似Masonry链式编程的方式初始化UIView、UIButton、UILabel、UIScrollview、UITextView、UITabelView...

image

Installation with CocoaPods

CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries. You can install it with the following command:

$ gem install cocoapods

Podfile

To integrate KMUIMaker into your Xcode project using CocoaPods, specify it in your Podfile:

In your Podfile

pod 'KMUIMaker'

Then, run the following command:

$ pod install

Requirements

This library requires iOS 8.0+

Architecture

KMUIMaker

  • KMUIViewMaker
  • KMLabelMaker
  • KMImageViewMaker
  • KMUIControlMaker
  • KMButtonMaker
  • KMTextFieldMaker
  • KMScrollViewMaker
  • KMTableViewMaker
  • KMCollectionViewMaker
  • KMTextViewMaker

KMUIMakerCategory

  • UIView+KMUIViewMaker
  • UILabel+KMLabelMaker
  • UIImageView+KMImageViewMaker
  • UIButton+KMButtonMaker
  • UITextField+KMTextFieldMaker
  • UIScrollView+KMScrollViewMaker
  • UITableView+KMTableViewMaker
  • UICollectionView+KMCollectionViewMaker
  • UITextView+KMTextViewMaker

Usage

    ///UIView
    [UIView km_makeView:^(KMUIViewMaker *make) {
        make
        .frame(CGRectMake(100, 84, 150, 130))
        .backgroundColor([UIColor lightGrayColor])
        .cornerRadius(5)
        .borderWidth(1)
        .borderColor([UIColor cyanColor])
        .clipsToBounds(YES)
        .addToSuperView(self.view)
        .addSubview([UILabel km_makeLabel:^(KMLabelMaker *make) {
            make
            .font([UIFont systemFontOfSize:11])
            .text(@"我是Label")
            .textColor([UIColor redColor])
            .textAlignment(NSTextAlignmentRight)
            .userInteractionEnabled(YES)
            .addGestureRecognizer([[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapLabel:)])
            .frame(CGRectMake(10, 10, 80, 50))
            .backgroundColor([UIColor colorWithRed:0.1 green:0.1 blue:0.7 alpha:0.7]);
        }]);
    }];

    ///UIButton
    [UIButton km_makeButton:^(KMButtonMaker *make) {
        make
        .titleForState(@"我是Button", UIControlStateNormal)
        .titleColorForState([UIColor whiteColor], UIControlStateNormal)
        .addTargetAndActionForControlEvents(self, @selector(clickButton:), UIControlEventTouchUpInside)
        .frame(CGRectMake(100, 100, 200, 100))
        .center(self.view.center)
        .backgroundColor([UIColor colorWithRed:1 green:0 blue:0 alpha:0.7])
        .cornerRadius(8)
        .shadowRadius(3)
        .shadowOpacity(1)
        .shadowColor([UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:0.7])
        .shadowOffset(CGSizeMake(3, 3))
        .addToSuperView(self.view);
    }];
    

image

Author

hkm5558, [email protected]

License

KMUIMaker is available under the MIT license. See the LICENSE file for more info.

kmuimaker's People

Contributors

hkm5558 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

kmuimaker's Issues

精简代码量的一点建议

我也很喜欢链式编程的黑魔法,但是感觉楼主如果当初使用了函数宏来实现基础 UI 控件的链式编程效果,能给自己降低不少工作负荷.
👇下面是能够实现链式语法的函数宏

#ifndef AAGlobalMacro_h
#define AAGlobalMacro_h


#define AAObject(objectName) [[objectName alloc]init]


#define AAPropStatementAndFuncStatement(propertyModifier,className, propertyPointerType, propertyName)                  \
@property(nonatomic,propertyModifier)propertyPointerType  propertyName;                                                 \
- (className * (^) (propertyPointerType propertyName)) propertyName##Set;

#define AAPropSetFuncImplementation(className, propertyPointerType, propertyName)                                       \
- (className * (^) (propertyPointerType propertyName))propertyName##Set{                                                \
return ^(propertyPointerType propertyName) {                                                                            \
self.propertyName = propertyName;                                                                                       \
return self;                                                                                                            \
};                                                                                                                      \
}

#endif /* AAGlobalMacro_h */

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.