Latest 0.0.2
Homepage https://github.com/yqing0115/YQButton
License MIT
Platforms ios 8.0, requires ARC
Authors

自由设置按钮上的Image和Label的位置

Simulator_Screen_Shot_iPhone6s_YQButtonDemo.png

1.图片在标题上方

//图片在标题上方
YQButton *btn1 = [[YQButton alloc] initWithFrame:CGRectMake(20, 90, 100, 70) imageAtTop:3 space:2];
btn1.layer.borderWidth = 0.67;
btn1.layer.borderColor = UIColor.grayColor.CGColor;
[btn1 setImage:[UIImage imageNamed:@“icon_photo”] forState:UIControlStateNormal];
[btn1 setTitle:@“title text” forState:UIControlStateNormal];
[btn1 setTitleColor:UIColor.blackColor forState:UIControlStateNormal];
[self.view addSubview:btn1];

2.图片在标题下方

//图片在标题下方
YQButton *btn2 = [[YQButton alloc] initWithFrame:CGRectMake(135, 90, 100, 70) imageAtBottom:3 space:4];
btn2.layer.borderWidth = 0.67;
btn2.layer.borderColor = UIColor.grayColor.CGColor;
[btn2 setImage:[UIImage imageNamed:@“icon_photo”] forState:UIControlStateNormal];
[btn2 setTitle:@“title text” forState:UIControlStateNormal];
[btn2 setTitleColor:UIColor.blackColor forState:UIControlStateNormal];
[self.view addSubview:btn2];

3.图片在左边,标题自适应

//图片在左边,标题自适应
YQButton *btn3 = [[YQButton alloc] initWithFrame:CGRectMake(20, 175, 200, 50) imageAtLeft:3 space:4];
btn3.layer.borderWidth = 0.67;
btn3.layer.borderColor = UIColor.grayColor.CGColor;
[btn3 setImage:[UIImage imageNamed:@“icon_photo”] forState:UIControlStateNormal];
[btn3 setTitle:@“title text” forState:UIControlStateNormal];
[btn3 setTitleColor:UIColor.blackColor forState:UIControlStateNormal];
[self.view addSubview:btn3];

4.图片在右边,标题自适应,且标题靠近图片

//图片在右边,标题自适应,且标题靠近图片
YQButton *btn4 = [[YQButton alloc] initWithFrame:CGRectMake(20, 240, 200, 50) imageAtRight:3 space:4];
btn4.layer.borderWidth = 0.67;
btn4.layer.borderColor = UIColor.grayColor.CGColor;
[btn4 setImage:[UIImage imageNamed:@“icon_photo”] forState:UIControlStateNormal];
[btn4 setTitle:@“title text” forState:UIControlStateNormal];
[btn4 setTitleColor:UIColor.blackColor forState:UIControlStateNormal];
[self.view addSubview:btn4];

5.自定义图片和标题位置

//自定义图片和标题位置
YQButton *btn5 = [[YQButton alloc] initWithFrame:CGRectMake(20, 305, 100, 70) imageFrame:CGRectMake(25, 14, 40, 41) titleFrame:CGRectMake(15, 30, 70, 21)];
btn5.layer.borderWidth = 0.67;
btn5.layer.borderColor = UIColor.grayColor.CGColor;
[btn5 setImage:[UIImage imageNamed:@“icon_photo”] forState:UIControlStateNormal];
[btn5 setTitle:@“title text” forState:UIControlStateNormal];
[btn5 setTitleColor:UIColor.blackColor forState:UIControlStateNormal];
[self.view addSubview:btn5];

End

Latest podspec

{
    "name": "YQButton",
    "version": "0.0.2",
    "summary": "YQButton can easy to set image and label position.",
    "homepage": "https://github.com/yqing0115/YQButton",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "u6768u6e05": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/yqing0115/YQButton.git",
        "tag": "0.0.2"
    },
    "source_files": "YQButtonDemo/YQButtonDemo/YQButton/*.{swift,h,m,c}",
    "exclude_files": "Classes/Exclude",
    "requires_arc": true
}

Pin It on Pinterest

Share This