CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.

CSButton 0.5.2

CSButton 0.5.2

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Feb 2018

Maintained by Joslyn wu, Joslyn.



CSButton 0.5.2

Custom the position of the ImageView relative to the titleLabel in UIButton.

一个UIButon的派生类,可以调整图片与文字相对位置,图片和文字间距,以及图片显示大小。

效果图

接入

  • 方式一:Cocoapods导入

pod 'CSButton'

  • 方式二:直接将下面文件添加(拖入)项目中
CSButton.h
CSButton.m

功能

1、 调整图片与文字相对位置, 配置cs_buttonImagePositionType属性即可。

@property (nonatomic, assign) CSButtonImagePositionType cs_buttonImagePositionType;

该属性为枚举类型:

typedef NS_ENUM(NSInteger, CSButtonImagePositionType) {
    CSButtonImagePositionTypeDefault,
    CSButtonImagePositionTypeRight, 
    CSButtonImagePositionTypeTop, 
    CSButtonImagePositionTypeBottom 
};

2、 调整图片与文字间的距离, 配置cs_middleDistance属性即可。

@property (nonatomic, assign) CGFloat cs_middleDistance;

3、 调整图片展示大小, 配置cs_imageViewSize属性即可。

@property (nonatomic, assign) CGSize cs_imageViewSize;

说明

  1. 文字和图片都遵循水平竖直居中。
  2. 默认关闭了点击时图片高亮效果。如果需要开启则设置adjustsImageWhenHighlightedYES

Clone

git clone --recursive https://github.com/chenaiwubu/CSButton.git