Latest 0.0.2
Homepage https://github.com/1ilI/Y_ImageTitleButton
License MIT
Platforms ios 9.0
Frameworks UIKit
Authors

Y_ImgTitlButton

对 UIButton 进行封装,快速创建一个带有图片和标题的按钮。

功能

以前定义一个带有图片和标题的按钮,要想按照自己的方式排布,免不了要用到 contentVerticalAlignment、contentHorizontalAlignment、imageEdgeInsets、titleEdgeInsets 等之类的。

现在只需要通过自定义的按钮类型,如上图下字、左图右字等,来创建带有图片和标题的按钮,方便使用。

定义的枚举类型如下:

typedef enum {
    ImageTopTitleBottom,        //图上字下
    TitleTopImageBottom,        //图下字上
    ImageLeftTitleRight,        //图左字右
    TitleLeftImageRight,        //图右字左

    ImageLeftTitleRightLeft,    //图左字右 字靠右
    ImageLeftTitleRightCenter,  //图左字右 字居中

    TitleLeftImageRightCenter,  //图右字左 字居中
    TitleLeftImageRightLeft,    //图右字左 图靠左

    FitTitleLeftImageRight,     //图右字左适应
}ButtonStyle;

使用

  • 普通使用
    
    //创建一个图上字下的按钮
    Y_ImgTitlButton *button = [[Y_ImgTitlButton alloc] initWithStyle:ImageTopTitleBottom];

* 带有 margin 的按钮
```objc
//设置按钮的 margin
Y_ImgTitlButton *button = [[Y_ImgTitlButton alloc] initWithStyle:ImageTopTitleBottom margin:UIEdgeInsetsMake(10, 20, 30, 40)];
  • 带有 margin 和 padding 的按钮
    
    //设置按钮的 margin
    Y_ImgTitlButton *button = [[Y_ImgTitlButton alloc] initWithStyle:ImageLeftTitleRight margin:UIEdgeInsetsMake(0, 0, 0, 0) padding:CGSizeMake(20, 2333)];


## Example
![show](ImageTitleButtonExample.gif)

详细使用参见 Example

Latest podspec

{
    "name": "Y_ImageTitleButton",
    "version": "0.0.2",
    "summary": "u521bu5efau5e26u6709u56feu7247u548cu6807u9898u7684u6309u94ae",
    "description": "u6839u636eu81eau5b9au4e49u7684u679au4e3eu7c7bu578buff0cu5febu901fu521bu5efau4e00u4e2au5e26u6709u56feu7247u548cu6807u9898u7684u6309u94ae",
    "homepage": "https://github.com/1ilI/Y_ImageTitleButton",
    "screenshots": "https://raw.githubusercontent.com/1ilI/Y_ImageTitleButton/master/ImageTitleButtonExample.gif",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "1ilI": "1ilI"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source": {
        "git": "https://github.com/1ilI/Y_ImageTitleButton.git",
        "tag": "0.0.2"
    },
    "source_files": [
        "Y_ImageTitleButton",
        "Y_ImageTitleButton/**/*.{h,m}"
    ],
    "frameworks": "UIKit"
}

Pin It on Pinterest

Share This