Latest 1.0.1
License MIT
Platforms ios 8.0, requires ARC
Frameworks UIKit, Foundation
  • 1.Set view’s Frame from a string.
  • 2.A quick method to set view’s Property.

1.Set view’s Frame from a string.

example0: the beginning.

UIView *view1 = [[UIView alloc] init];

view1.frame = CGRectMake(20,20,40,20);

view1.frame = [self.view jhRectFromString:@"[x:20,y:20,w:40,h:20]"];

example1: set view’s width is half of ther screen.

UIView *view1 = [[UIView alloc] init];

view1.frame = CGRectMake(0,20,self.view.frame.size.width/2,20);

view1.frame = [self.view jhRectFromString:@"[x:0,y:20,w:2_w(0),h:30]"];
//self.view's tag is 0.

example2: put view1 at the center of self.view.

//view1's width is 50,height is 50.
UIView *view1 = [[UIView alloc] init];

view1.frame = CGRectMake((self.view.frame.size.width - 50)/2,(self.view.frame.size.height - 50)/2,50,50);

view1.frame = [self.view jhRectFromString:@"[x:2_w(0)-25,y:2_h(0)-25,w:50,h:50]"];

more methods, find yourself.

2.A quick method to set view’s Property.

example0: view.

    UIView *view = [[UIView alloc] init];

    view.frame = CGRectMake(20,40,50,30);
    view.backgroundColor = [UIColor redColor];
    view.layer.borderWidth = 2;
    view.layer.borderColor = [UIColor blueColor].CGColor;
    view.layer.cornerRadius = 5;
    view.layer.masksToBounds = YES;
    view.tag = 5;

    .jh_bgColor([UIColor redColor])
    .jh_bdColor([UIColor blueColor])

example1: label.

    UILabel *label = [[UILabel alloc] init];
    .jh_bdColor([UIColor blueColor])

example2: button.

    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];

notice: jh_addToView should be called before jh_frame.

  • more support: textField,textView,tableView,scrollView.
  • need more, do it yourself.

Latest podspec

    "name": "JHCategories",
    "summary": "A chainable categories for UIView",
    "version": "1.0.1",
    "license": {
        "type": "MIT"
    "authors": {
        "Haocold": "[email protected]"
    "homepage": "",
    "platforms": {
        "ios": "8.0"
    "source": {
        "git": "",
        "tag": "1.0.0"
    "source_files": "JHCategories/**/*.{h,m}",
    "public_header_files": "JHCategories/**/*.{h}",
    "requires_arc": true,
    "frameworks": [

Pin It on Pinterest

Share This