Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/CenterY/UIButtonEdgeInsets
通过类别和继承方式实现按钮的图片和标题布局,调整 UIButton的imageEdgeInsets 和titleEdgeInsets属性
https://github.com/CenterY/UIButtonEdgeInsets
Last synced: 20 days ago
JSON representation
通过类别和继承方式实现按钮的图片和标题布局,调整 UIButton的imageEdgeInsets 和titleEdgeInsets属性
- Host: GitHub
- URL: https://github.com/CenterY/UIButtonEdgeInsets
- Owner: CenterY
- License: mit
- Created: 2015-06-28T15:45:49.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-06-28T16:33:51.000Z (over 9 years ago)
- Last Synced: 2023-11-07T17:16:42.877Z (about 1 year ago)
- Language: Objective-C
- Size: 238 KB
- Stars: 104
- Watchers: 5
- Forks: 21
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - UIButtonEdgeInsets - 通过类别和继承方式实现按钮的图片和标题布局,调整 UIButton的imageEdgeInsets 和 titleEdgeInsets属性。【 [Priview 1](https://github.com/CenterY/UIButtonEdgeInsets/raw/master/images/image_left.png) | [Priview 2](https://github.com/CenterY/UIButtonEdgeInsets/raw/master/images/image_right.png) 】 (OOM-Leaks-Crash / Categories-Extensions)
README
# UIButtonEdgeInsets
通过类别和继承方式实现按钮的图片和标题布局,调整 UIButton的imageEdgeInsets 和titleEdgeInsets属性### 按钮布局结构
![](images/image_left.png)
![](images/image_right.png)
![](images/image_top.png)
![](images/image_bottom.png)### 两种方式实现按钮图片标题的布局
### (一) 使用 HYEdgeInsetsButton (UIButton子类)
使用代码或者在Interface Builder调整 edgeInsetsStyle (HYButtonEdgeInsetsStyle 枚举) 和 imageTitleSpace (CGFloat) 两个属性// edgeInsetsStyle
typedef NS_ENUM(NSUInteger, HYButtonEdgeInsetsStyle) {
HYButtonEdgeInsetsStyleImageLeft,
HYButtonEdgeInsetsStyleImageRight,
HYButtonEdgeInsetsStyleImageTop,
HYButtonEdgeInsetsStyleImageBottom
};
// imageTitleSpace 为图片标题间距#### Interface Builder 调整
![](images/interface_edgeinsets.png)
### (二) 使用 类别 UIButton+EdgeInsets
- (void)layoutButtonWithEdgeInsetsStyle:(ButtonEdgeInsetsStyle)style imageTitlespace:(CGFloat)space;
// style
typedef NS_ENUM(NSUInteger, ButtonEdgeInsetsStyle) {
ButtonEdgeInsetsStyleImageLeft,
ButtonEdgeInsetsStyleImageRight,
ButtonEdgeInsetsStyleImageTop,
ButtonEdgeInsetsStyleImageBottom
};
// space为图片标题间距![](images/space_h.png)
![](images/space_v.png)